📜 ⬆️ ⬇️

Useful and interesting modules for Drupal 6.xx + Tips and Tricks (Part I)

In April last year, the habrayuser @ 7paca wrote an excellent article about useful modules and I decided to continue it

Modules:



Filefield Paths - allows you to create your own token-templates for files uploaded via filefield. Convenient for organizing photos in galleries (noted that does not work with Image FUpload ).
')
Uploadpath - allows token-templates to store files in directories or subdirectories.

Hide Submit - allows you to hide the “Submit” button after clicking. Protects against re-sending data.

Uploadify - multi- upload files. The module is still in development, but many are already beginning to use it.

WordPress Comments - For those who are used to the form of commenting a la Wordpress

Remember me - the module adds the “remember me” checkbox to the authorization form

Printer, e-mail and PDF versions - the module allows you to print a page, send it by mail and convert it to PDF

One page profile - no tabs in the profile of the user, everything is placed on one page. Very comfortably

Contact attach - allows users to attach files (attach) to the letter sent via the feedback form.

Flag - allows to mark materials, for example, “Add to bookmarks”. There is a view output to the user page. Perfectly customizable for any needs.

XML sitemap - sitemap generation.

Comment Notify - convenient subscription to comments

LoginToboggan is a very convenient module for organizing authorization using both login and email. A lot of opportunities.

Scheduler with this task scheduler can easily publish or remove from publication materials on a specific date.

Imagecache Actions - the module allows you to assign presets to loaded images, for example, watermark overlay, text overlay, background lining, etc.

Privatemsg - module for organizing internal correspondence between site users

Some tips (use them in your projects or not - your right):


JQuery field fill check


I personally don’t like the Drupal validator and I integrated jquery.validate

Actually integrating it is not a problem.
Download the plugin.
Create a js directory in your theme directory and put jquery.validate.min.js there.

Open YOUR_TEMA.info and connect the plugin there:
scripts[] = js/jquery.validate.min.js

* This source code was highlighted with Source Code Highlighter .


The js directory should be on the path / sites / all / themes / your_theme /

Create a scripts.js file in the / sites / all / themes / your_teme / js / directory and put the following in it:

$().ready(function() {
$( "#comment-form" ).validate();
});
</pre>


* This source code was highlighted with Source Code Highlighter .


Note: you can insert all your scripts in the same file.

If you want to check if the fields are filled in during registration, do this:

$().ready(function() {
$( "#comment-form, #user-register" ).validate();
});


* This source code was highlighted with Source Code Highlighter .


Note: # comment-form is the form identifier that we are checking. You can find the ID by looking at the page code.

Everything!

Target = _blank solution


Paste this code into /sites/all/themes/your_theme/js/scripts.js

$(function(){
$( '._blank a' ).click(function(){
window.open( this .href);
return false ;
});
});


* This source code was highlighted with Source Code Highlighter .


Example of use:

< span class =" _blank >< a href ="http://habrahabr.ru" > Habrahabr </ a ></ span >

* This source code was highlighted with Source Code Highlighter .


Or, if the link is found in the text -

< div class ="content _blank" >
< p >
< a href ="http://www.lipsum.com/" > Lorem ipsum </ a > dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. < a href ="http://www.lipsum.com/" > Excepteur </ a > sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</ p >
</ div >


* This source code was highlighted with Source Code Highlighter .


Adding a span tag to primary / secondary_links


Paste this code into /sites/all/themes/your_theme/js/scripts.js

// Wrap span tags around the anchor text in the primary menu.
$(document).ready(function(){
$("#primary li a")
.wrapInner(" < span > " + " </ span > ");
});


* This source code was highlighted with Source Code Highlighter .


and in the template.php of our theme this code:

/**
* Override the theme_links function
*
* We use this to insert <span></span> tags around anchor text in the
* primary and secondary links. We need these to support Internet Explorer
* when building sliding door tabs with hover effects.
*/
function __links($links, $attributes = array( 'class' => 'links' )) {
$output = '' ;
if (count($links) > 0) {
$output = '<ul' . drupal_attributes($attributes) . '>' ;

$num_links = count($links);
$i = 1;

foreach ($links as $key => $link) {
$ class = $key;

// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$ class .= ' first' ;
}
if ($i == $num_links) {
$ class .= ' last' ;
}
if (isset($link[ 'href' ]) && ($link[ 'href' ] == $_GET[ 'q' ] || ($link[ 'href' ] == '<front>' && drupal_is_front_page()))) {
$ class .= ' active' ;
}

$output .= '<li' . drupal_attributes(array( 'class' => $ class )) . '>' ;

// wrap <span>'s around the anchor text
if (isset($link[ 'href' ])) {
$link[ 'title' ] = '<span>' . check_plain($link[ 'title' ]) . '</span>' ;
$link[ 'html' ] = TRUE;
// Pass in $link as $options, they share the same keys.
$output .= l($link[ 'title' ], $link[ 'href' ], $link);
}
else if (!empty($link[ 'title' ])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link[ 'html' ])) {
$link[ 'title' ] = check_plain($link[ 'title' ]);
}
$span_attributes = '' ;
if (isset($link[ 'attributes' ])) {
$span_attributes = drupal_attributes($link[ 'attributes' ]);
}
$output .= '<span' . $span_attributes . '>' . $link[ 'title' ] . '</span>' ;
}

$i++;
$output .= "</li>\n" ;
}

$output .= '</ul>' ;
}
return $output;
}

* This source code was highlighted with Source Code Highlighter .


Sorting Views Templates


It is very unpleasant when there are a lot of templates in / sites / all / themes / our_theme /. Even to ugliness a lot. Of course, there will be no confusion if it was you who made the theme for your website or blog, but a large number of files in the theme directory are annoying!

There is a solution!

Create a views folder in the theme directory and transfer all your view-view templates there — gallery-page.tpl.php (or similar).

Go to the theme settings (/ admin / build / themes / settings) and click save.

If there are problems, for example, error output that something was not found, go to any created view and click Rescan (rescan), save the view. Everything. Now more or less order.
There is information on the organization of the Views templates.

Good luck!

UPD: krig made a valuable comment

construction
$( document ).ready( function (){
// do some fancy stuff
});


* This source code was highlighted with Source Code Highlighter .

change to
Drupal.behaviors.myModuleBehavior = function (context) {
//do some fancy stuff
};


* This source code was highlighted with Source Code Highlighter .


→ Part II

Source: https://habr.com/ru/post/80565/


All Articles