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 →

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 
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 →

Sep, 2014
sivaji's picture

7 Comments | Submitted by sivaji

Mobile Friendly Navigation Toolbar, shortly known as navbar, is a back-port of toolbar in Drupal 8. The problem it tries to solve is pretty obvious from it's name.

Navbar is an often used module in our Drupal projects. In our recent project we were asked to develop a bunch of menus to quickly access admin pages as and when needed. Unlike Shortcuts, we want this appear dynamically like notification.

For instance, if there are any new comments awaiting approval, the menu should show up and a few more items similar to this. Thought, Navbar could be leveraged for this requirements.

This mighty developer friendly module makes this possible for any module by implementing hook_navbar(). Similar to hook_menu(), an array of menu items to be returned but in renderable array format. If you need an example, function navbar_navbar() is a good place to get started.

The menu it offers can be seen as,

  1. The navbar tab by its name acting as menu item (e.g. Home)
  2. The navbar tab on click expands to show menu item(s) it has got underneath (e.g. Shortcuts) depends on the way navbar item defined in the hook_navbar().

Example code for #1,

Read more →

Sep, 2014
sivaji's picture

4 Comments | Submitted by sivaji

We wanted to have a quick clear button for any text field (similar to address bar of browsers in mobile and tablet devices). Snapshot below might explain it much better. In this you are seeing email search field in newsletter filter form.

While I was in search for creating this, I found HTML5 is as the way to go. One can simply create that by using "search" input type. The proper HTML tag for the same is below,

Read more →

Aug, 2014
sivaji's picture

5 Comments | Submitted by sivaji

Although Webform module comes with limited integration to expose the submitted data in Views, it lacks the fine control to make View by Webform field as rows and columns. There is a workaround to achieve this though which I would like to briefly run through in this blog.

Webform MySQL Views together with Data and Schema modules with a patch to Webform MySQL Views from issue #889306: Allow the designation of a primary key for MySQL views makes this feasible.

Webform MySQL Views, as the name implies, allow us to create MySQL view from Drupal, leveraging the Data module which counts on Schema module.

Data module wraps a bundle of sub-modules, among them Data Search provides Views Integration and Data Admin UI for accessing its administrative pages.

Once the mentioned modules are enabled. You can see a sub-menu "MySQL Views" under Administration » Content » Webforms. Tick the Webform node whose fields are needed in Views. This form is only meant to create MySQL view.

Read more →

Subscribe to RSS - Drupal 7

Get a quote