To create GIT patches using branches (which is required for drush make):
git clone --branch 7.x-1.x
cd session_api
git checkout -b cron
[edit code...]
git commit -a -m "Use an expiration logic when clearing sessions on cron"
git checkout 7.x-1.x
git diff --no-prefix 7.x-1.x cron > session_api_cron.patch

You may use the "master" branch instead of "7.x-1.x".

Recently, I had to use Facebook API for a web site using social networks. When testing these APIs, having test accounts is necessary. Facebook provides an API to create, delete and modify these friends. Here is a handy code snippet which makes it easy to batch create, delete, list test accounts and connect them as friends.

A zipped version is attached below.

Here is a simple database API example :

$results = db_select('authmap', 'am') // 'authmap' is the table name, 'am' the alias
->fields('am', array('uid')) // The alias and the field we want to fetch
->distinct() // Add distinct
->condition('module', 'MYMODULE') // A condition on the 'module' field, 'MYMODULE' value
->condition('authname', $ids, 'IN') // A condition on the 'authname' field, value is in $ids array
->execute() // Execute the query
->fetchCol(); // Fetch column

There are many examples on how to use AJAX using form API, but I could not find a good example on how to use AJAX with markup. Here is a simple method.

To create an AJAX link in Drupal, outside of form API, we first need to add a menu item :

function MYMODULE_menu() {
$items = array();
$items['MYMODULE/ajax'] = array(
'page callback' => 'MYMODULE_ajax_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
$items['MYMODULE/ajax/%/%'] = array(
'page callback' => 'MYMODULE_ajax_callback',
'page arguments' => array(2, 3),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
return $items;

Then, wherever you want to create a link, include the library :

// Add libraries
drupal_add_library('system', 'drupal.ajax');
drupal_add_library('system', 'jquery.form');

Create a link with the "use-ajax" class and a wrapper for the AJAX response. This is a dummy example, you must do this in an appropriate way of course :

// Output a link
l(t('AJAX'), 'MYMODULE/ajax/nojs/' . $some_argument, array('attributes' => array('class' => array('use-ajax'))));
// Output a wrapper
'<div id="MYMODULE-wrapper"></div>'

Finally, create your callback function :

function MYMODULE_ajax_callback($type = 'ajax', $some_argument) {
if ($type == 'ajax') {
$commands[] = ajax_command_replace('#MYMODULE-wrapper', 'Hey ! Some AJAX content !');
$page = array('#type' => 'ajax', '#commands' => $commands);
else {
$output = t("This is some content delivered via a page load.");
return $output;

That's it !

Sometimes we need to add template suggestions to a module. To do this, we need to alter the registry and add the template suggestion to the preprocess function.

To add a template suggestion for blocks named "mytemplate.tpl.php" in the "theme" subfolder of your module, do the following :

* Implementation of hook_theme_registry_alter().
function MYMODULE_theme_registry_alter(&$theme_registry) {
  $theme_registry['block']['theme paths'][] = drupal_get_path('module', 'MYMODULE') . '/theme';
* Implementation of hook_preprocess_block().
function MYMODULE_preprocess_block(&$variables) {
  $variables['template_files'][] = 'mytemplate';

To extend a jQuery UI widget with your own widget, 3 important things :

  • jQuery UI uses the data() function to store information related to the widget. The data identifier of the element will be your widget name, so you must copy its value to the original data value.
  • For each function you want to extend, call the original function of the widget with apply().
  • Set the default options.

$.widget("ui.customsortable", $.extend({}, $.ui.sortable.prototype, {
  _init: function(){'sortable','customsortable'));
    return $.ui.sortable.prototype._init.apply(this, arguments);
  // Override other methods here.
$.ui.customsortable.defaults = $.extend({}, $.ui.sortable.defaults);

Freshy 2 theme and Customize plugin have been updated for Wordpress 2.9. I just followed instructions at and did not test this out. Please tell me if everything is fine.

Since I do not have time for Freshy 2 and Customize development, I will put source code on GitHub to allow other developers to help maintain code for future releases.

Finally !
It is more than 2 years now that i am involved with Drupal and my Wordpress site was dying. After creating Likwid, a web agency specialized in Drupal, I could not find time to make a new version of my site.
Since the site literally exploded, i had to rush and quickly finish the work I started... over a year ago.
Wordpress fans may be a little disappointed since I probably won't do any Wordpress related work anymore. But when I'll have some more time, I'll release the site theme to the Drupal community.
That's a new start and I will post again on this site.
See you soon !

Here it is ! The 2.7 compatible version of Freshy (version 2.1) is out ! Grab it while it is hot ! Freshy 2.1

A new release for customize has also been released, update it too :
Customize 1.0.4

Enjoy !

This site has been really quiet recently. I have been busy with my work and did not have time for Freshy. But I have some news for you !

Freshy 2.1 is almost ready, it will be compatible with wordpress 2.7, numerous bugs have been corrected et some features have been dropped since it was becoming hard to maintain. I know some of you have been waiting a long time for such news, thanks for having been so patient.

My site will be totally redesigned. I will swicth to Drupal, with a whole new theme that will be released on this site too. I am focusing on Drupal now, and will release themes and modules. This is also the occasion to post again.

Stay tuned !

Syndicate content