06
Nov, 2014
Manikandan's picture

0 Comments | Submitted by Manikandan

The AmazonS3 module allows the drupal local file system to be replaced with S3, where the files can be uploaded or downloaded from S3. I used the following modules to achieve this:
 
Download and install these modules and place SDK library at sites/all/libraries/awssdk.
Check  'Status report'  for information about the installation of  AmazonS3 and AWSSDK.
 
 
Here we go:
 
  •  In admin/config/media/amazons3, give your default bucket name which you would have created in S3.

          

Read more →

05
Nov, 2014
suresh's picture

3 Comments | Submitted by suresh

In Drupal views, we have the option of exposing the filters to users. By default, the exposed filters are displayed as Select boxes. Recently in a multilingual project, there was a requirement to display Courses based on Language. And the Languages had to be shown as links. In order to achieve this functionality, the Views exposed filter had to be customized.

To start with the customization, we need to alter "views_exposed_form" using hook_form_alter

function module_name_form_alter(&$form, &$form_state, $form_id) {
  global $language;
  if ($form['#id'] == 'views-exposed-form-course-listing-page') {
    $links = $form['language']['#options'];
    $vars = array();
    foreach ($links as $tid => $term_name) {
      if ($language->language != $tid && $tid != 'All')  {
        $options = array(
          'attributes' => array(
            'class' => array( 'course-filter-tab' . $tid),
            'id' => $tid,
          ),
          'html' => TRUE,
        ),
        $language_list = language_list();
        $language_title = $language_list[$tid]->name;
        $vars['items'][] = l($language_title, "course", $options);
      }
    }
    $vars['type'] = 'ul';
    $vars['attributes']['class'] = array('course-tabbed-filter');
    $prefix = theme('item_list', $vars);
    $form['links'] = array(
      '#markup' => $prefix,
    );
  }  
}
       

The above code will help us render the select box as link, but to make the links functional we need some jQuery code.

Read more →

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 →

Subscribe to RSS - Drupal planet

Get a quote