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





Facebook Live Stream module released on drupal.org

13 06 2009

Finally we got cvs login for the drupal.org to put our module in the drupal contributions section. Now facebook like stream module is available at location http://drupal.org/project/facebook_stream

I got cvs login after 11days of applying for the cvs. It is not so easy to get cvs login. I sent request through the http://drupal.org/cvs-application/requirements link. It is must to follow the instructions specified in the above link. I was talking about this in the #drupal IRC channel. Finally got the cvs login.





Formula to calculate number of hours in google spreadsheet

8 06 2009

I was keeping my timesheet on google spread sheet. I was just mentioning start time and end time of particular task. My project manager asked me to add number of hours as another column.

When I search for the formula I found this link http://www.google.com/support/forum/p/Google+Docs/thread?tid=071c90492bf64b75&hl=en . In that link I found solution to my problem.

I need to keep start time in one column(ex: A4 with value 10:50:00), end time in another column(ex.B4 with value 13:42:00). I should maintain time in 24 hours format. I have another column called Hours(ex. D4 should have 2.9 hours).

The cell value for Hours column should be difference of time from B4 and A4 in terms of hours. So I used =ROUND(ABS(B4-A4) * 24, 1) formula in that cell. I got the exact number of hours I spent. Just drag the column with ‘+’ to affect the same formula for the rest of the cells in the hours column.