Drupal module is not appearing in module list page

10 07 2009

Recently when I am working on one project I observed strange behavior. The module is there in the modules directory but I can’t see that module in the admin/build/modules/list page. I wanted to enable that module but I could not find that module in the list.

I was struggling to find out why? After some time one of my colleague said to search for this module .module file exist in some other location also. Yes it is there in another folder. If I remove that extra .module file which is there at wrong location it appear in the modules list page.

.module file should exist at only single palce. This probllem can be common when we use ftp to copy files. By mistake we can put files in some other location. So be careful while copying files using FTP.


Using GMap + Location + Views Drupal Modules

5 07 2009

Recently I got a chance to work on GMaps using drupal. GMap and Location modules are very good to integrate GMap with drupal. Views module made my life very easy.

Installing GMap + Views

1. Install views and enable views and views UI module

2. Install GMap and locations module and enable GMap, Location, GMap Location, Node Locations, User Locations, Location Add Another modules

3. Go to admin/settings/gmap page and add the gmap api key, which we can get through http://www.google.com/apis/maps/signup.html and adjust other map settings

4. Go to admin/settings/gmap_location page and adjust the gmap macro settings if needed.

5. Go to content type edit page and adjust the location settings.

6. Add the nodes by specifying some locations.

7. Go to map/node page which will show GMap with node locations marked.

Creating GMap View

Creating of view is normal, just select the view style as GMap. The result of the query values will display as markers on GMap.

GMap Macros

A GMap macro is a text-based way of describing arbitrary GMaps. We can build this macro using GMap Macro Builder module.

1. Enable GMap Macro Builder Module

2. Go to map/macro or click on the Build GMap Macro link in the Navigation to build macro.

3. Audgest the GMap settings, at the down in the Macro text box the text representation of map will be updated.Copy this text and use when ever is needed.

Using GMap Macro

We can use this GMap macro on any node. To display GMap on any node (ex: page) just copy the above GMap macro text and place it in the body text and choose the Input format GMap. To get input format GMap just add one input format like this.

1. Go to admin/settings/filters/add page

2. Type the name of the filter as GMap

3. Choose the GMap macro Expander and save.

I hope this will be helpful for others.

Note: I used Drupal 6.12 version.

Facebook Stream module allows publish functionality

27 06 2009

Now Facebook stream drupal module allows users to publish comments, likes and status messages.  For demo check http://drupal.azrisolutions.com/facebook_stream/

To allow users of your application publish posts,  comments, likes you need to apply for the whitelist. Otherwise, the only Facebook users that can grant your application the publish_stream permission are the developers of your application.

Providing default view with your module.

20 06 2009

Recently we released Twitter Search Feeds module. I wanted to provide default view with this module. To do that I did following steps.

1. Implemeted hook_views_api function like this.
function modulename_views_api() {
return array(
'api' => 2,
'path' => drupal_get_path('module', 'modulename'),

2. Exported the view that I wanted to keep in my module and stored the exported content in a file with the name MODULENAME.views.inc like this.

function modulename_views_default_views() {
$views = array();
// Start copy and paste of Export tab output.
// End copy and paste of Export tab output.
// Add view to list of views to provide.
$views[$view->name] = $view;
// ...Repeat all of the above for each view the module should provide.
// At the end, return array of default views.
return $views;

That’s it, when enable the module, this view will appear in the views list.

In the first step hook_views_api function is telling that we have a default view which is there in the module path.

In the second step we implemented hook_views_default_view with view structure. This function return the array of views. This method is for the views2/drupal6.

There is a very good article explaining this Speed Up and Version Your Views

Using custom template file in your drupal module

20 06 2009

Recently we released Accordion blocks module in drupal. This module should work with all standard drupal modules, otherwise this module is not useful. So to make it work with all themes, I decided to use my custom block.tpl.php which is there in my module. But by default drupal will load block.tpl.php from your theme. If there is not block.tpl.php in the theme then it will load block.tpl.php from the block module.

I used hook_theme_registry_alter() hook to load block.tpl.php from my module. I wrote my hook like this.

function example_module_theme_registry_alter(&$theme_registry) {
// using our own block.tpl.php file.
$theme_registry['block']['template'] = 'block';
$theme_registry['block']['path'] = drupal_get_path('module', 'example_module');
$theme_registry['block']['type'] = 'module';
$theme_registry['block']['theme path'] = drupal_get_path('module', 'example_module');
$theme_registry['block']['theme paths'] = Array();

Now after enabling my module every time block.tpl.php from my module is loading. This way we no need to alter any template file in the theme folder. This method only works for drupal6-7

update1: We can over write the theme function also. To over write theme function write theme registry alter hook like this.

function example_module_theme_registry_alter(&$theme_registry) {
// using our own block.tpl.php file.
$theme_registry['block']['function'] = 'theme_custblock'; // your custom theme function name
$theme_registry['block']['path'] = drupal_get_path('module', 'example_module');
$theme_registry['block']['type'] = 'module';
$theme_registry['block']['theme path'] = drupal_get_path('module', 'example_module');
$theme_registry['block']['theme paths'] = Array();

Find current theme regions in drupal

17 06 2009

I am working on a accordion_blocks module. For this module I wanted to enable the accordion effect for the blocks appearing in left and right regions. To do that I need to find our the regions of the theme. To find out the regions I used bellow code in the hook_theme_registry_alter function.

global $theme;
// Populate all block regions.
$regions = system_region_list($theme);

In the template_preprocess_page hook, I directly used $variables[‘left’], $variables[‘right’]

Accordion Blocks module for drupal released

17 06 2009

We recently released Accordion Blocks module in dupal. This module applies the accordion effect for the blocks appearing left and right side. Just install the dependend modules and this module, the accordion effect will apply to the blocks. We can change the theme of the accordion widget by changing the theme at admin/settings/jquery_ui path. These themes can be downloaded from jquery ui theme roller . This module works with all standard drupal themes.

Demo of the accordion blocks module is avaiable at http://drupal.azrisolutions.com/accordion_blocks_demo