28
Oct, 2014
Sujith's picture

1 Comments | Submitted by Sujith

Autocomplete is a feature for textfields in Drupal. It provides a dropdown list of matching options from the server. It is implemented through AJAX. To know how to add an autocomplete form element in Drupal visit https://www.drupal.org/node/854216

 

For customizing autocomplete we need to override the Drupal system file "misc/autocomplete.js". This can be achieved ideally in two ways:

  • Replace the entire "autocomplete.js" with your customised version

    function MY_MODULE_js_alter(&$javascript) {
      $javascript['misc/autocomplete.js']['data'] = drupal_get_path('module', 'MY_MODULE') . '/js/autocomplete.js';
    }
  • Override "Drupal.ACDB.prototype.search" with a custom behaviour in theme script.js or module js file, as long as it's added after /misc/autocomplete.js it will override it.

Read more →

28
Oct, 2014
Karalmax's picture

0 Comments | Submitted by Karalmax

I'm sure that this script will help you in some of your projects that needs a username and password.
Sometimes when we want access to a secure page that asks for a username and password and we submit the information but we didn't know that the password was submitted in upper case, we get an error.
 
Solution: 
jQuery('#username').keypress(function(e) {
  var s = String.fromCharCode( e.which );
  if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) {
    jQuery('#capslockdiv').show();
  }
  else {
    jQuery('#capslockdiv').hide();
  }
});
jQuery('#password').keypress(function(e) {
  var s = String.fromCharCode( e.which );
  if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) {
    jQuery('#capslockdiv').show();
  }
  else { 
    jQuery('#capslockdiv').hide();
  }
});

Sample HTML code

Read more →

27
Oct, 2014
Ganesan's picture

0 Comments | Submitted by Ganesan

      Nowadays twitter bootstrap theme has become famous among Drupal world due to its flexibility for responsive websites. It is very easy to apply responsive css to the web page by adding appropriate bootstrap classes. If you are new to the twitter bootstrap theme, see here http://getbootstrap.com/css/ for more details about classes. Is it easy to add class to drupal site pages ? If yes, what to do to add class to panel title and image tags ? Lets come to the heart of the topic.

Adding class to panel title

      Eventhough it is easy to apply responsive css to the web page, when comes to drupal site we need to follow some standard approaches for adding classes. I need to add class to panel title in one of my requirements. By sticking with standard approach for this, I found this hook template_preprocess_panels_pane very useful to add class to panel title. Below code snippet will explain more detail about the usage.

function themename_preprocess_panels_pane(&$variables) {
  $variables['title_attributes_array']['class'][] = 'your class';
}  

The above code snippet need to be written in theme's template.php file.

Adding class to img tags

      Then I need to add class to img tags to make the image responsive as one of my requirements. Similar to panel, I found this hook template_preprocess_image very useful to achieve this. See the below code snippet to know in detail

Read more →

15
Oct, 2014
selvam's picture

5 Comments | Submitted by selvam

Sometimes you could be in a fury when user picture gets deleted automatically with nothing being noticed as strange. Even this thread 935592 might not help you. Then you have come to right place. Ofcourse the culprit could be your call to user_save() somewhere. The actual issue might be, you are passing global user object instead of full account object. The first param of user_save() should be a full account object, while global user does not have all the data of account object. In this case $account->picture is an object while $user->picture is just an integer, fid (File id) of the image file. So while trying to save, your picture association with the user account gets broken. The reason can be understood by looking at the user_save() source code. The method checks for 
empty($account->picture->fid)
While using $user, this condition becomes false (we only have $account->picture not $account->picture->fid) and user picuter is removed.
So make sure you call like this,
global $user
$account = user_load($user->uid);
/*Some operations with $account object*/
user_save($account, $edit); /*NOT user_save($user, $edit)*/

Read more →

22
Sep, 2014
sivaji's picture

0 Comments | Submitted by sivaji

After Zen, Bootstrap has been our favorite theme framework for Drupal sites we build. Bootstrap embraces a lot of interesting features with it. One among them is Tour, which could give a quick walk-through of various things in a site with a brief summary in a popup/tooltip style.

We leverage this to give a quick introduction to various administrative links and their purpose to Drupal admin.

I wanted to change the template of Tour content to meet our design. I would like to explain the same in this post.

The below piece of code from Bootstrap Tour favors showing Tour content.

Read more →

Subscribe to RSS - Drupal planet