Changing the hook execution sequence of form hook.

 

Generally in drupal modules are executed in as per the weight in the specified by the system table. 

If two module has the same weight then modules are executed alphabetical order based on the name of module. 

 
During working on one of my project, I was working with workflow module. 

New version of workflow module adds Target State radio buttons on node form. I wanted to move these radio buttons to vertical tabs in node creation form. 

I created a module for the form_alter function. I named my module as my_module.module.

Adding custom access condition to menu item.

As Drupal is hailed as good CMS if you want to alter any existing thing.
The hook architecture of drupal makes it possible to alter any thing.
 
You can also add custom acess callback for any menu item.
To add custom menu access callback you can user hook_menu_alter() function.
 
As per the documentation this hook Alter the data being saved to the {menu_router} table after hook_menu is invoked.
 
This hook is invoked by menu_router_build(). The menu definitions are passed in by reference.
Each element of the $items array is one item returned by a module from hook_menu.
Tags: 

Adding role to user programatically

 

Recently i had some task, in which i wanted to add the specific role during registration programatically.
After searching in Drupal API, i came across two function that can do the task for me.
 
function user_role_load_by_name($role_name) 
 
This function fetches the role from the role name, and it will return a fully-loaded role object if a role with the given name exists, or FALSE otherwise.
 
I used this function to load the role object which i passed as string in $role_name.
 
Now function  user_multiple_role_edit() will allow to add roles to the users.
 
function
Tags: 

Display user email on the user profile view page to administrator users

 

Recently working with administrator account i encountered a problem. When i visit the profile of other user, i was not able to see the email id of the registered user.
 
To view the user email id either i have to goto the user profile and then click "Edit" tab for that account that will show the account for the user.
 
Now i wanted to show the email id of the register user to be displayed when administrator views the profile.
 
After little bit googling  i found a hook that can alter the view of the user profile
As we can see the description of  hook_user_view() this hook is called
Tags: 

Transform drupal search result page to infinite scroller

 

Hello,
If you want to transform pager of any page to infinite scroller you can do it using infinite scroll javascript.
To set it on any page, you will need a couple of steps:
I have transformed the search result page to infinite scroller.
For detail instructions you can follow this guide on drupal.org(http://drupal.org/node/1473558)
 
1) Download https://github.com/desandro/imagesloaded (jquery.imagesloaded.min.js) place it in your theme folder YOURTHEME/js
This will make sure all images are loaded before activate the infinite scroll.
 
2) Download
Tags: 

Pages