Skip to main content


knackforge blog knowledge base

Drupal cron-queue

Drupal cron queue is very useful while running a big cron job. It will split a big cron job into small chunks and execute without getting timed out or being abruptly ended.

Three important things to remember in queue implementations are

  1. Create cron queue in hook_cron_queue_info
  2. Fill the queue with data
  3. Define worker callback function

STEP 1 - Create cron queue in hook_cron_queue_info

knackforge blog knowledge base

Drupal 6: system_settings_form

Drupal has a rich set of API to aid us in implementing custom functionalities with minimal optimized code. One such utility is system_settings_form($form).

Recently in my project, I created a new admin configuration form, in that I had to set the all the field values as system variables. If I had not used system_settings_form(), then the code would have been like this.

How to automate backup

How to automate backup for our codebase & database

Most of the sites rely on codebase & database which we can't afford to lose. We definitely need to implement a backup procedure in that case, otherwise, we may lose our valuable data due to some kind of mishap (manually delete some data by mistake, software errors, hardware errors, server compromise, etc).

We can use the following shell script to make a backup (codebase and database).

First, let's create the backup script file:

nano /path/to/script/ 

and add the following code:

Background vidoes

How to set up a video background in Drupal 7 using the jquery.videobackground plugin

I’ve recently been working on a jQuery plugin that uses a HTML5 video as the background for a page. An idea that perhaps owes far too much of it’s inception to splash pages, it was worth investigating; as a test for HTML5 video player development and because of it’s interesting use of the video element.

This blog explains about how to set up video background in drupal. There are many plugins available to create background video in drupal and I am going to discuss jQuery videobackground plugin. The plugin should work in any browser that supports HTML5 video.

install XHProf

How to install XHProf (for Drupal)

XHProf is a hierarchical profiler for PHP. It reports function-level call counts and inclusive and exclusive metrics such as wall (elapsed) time, CPU time and memory usage. A function's profile can be broken down by callers or callees. The raw data collection component is implemented in C as a PHP Zend extension called xhprof. XHProf has a simple HTML based user interface (written in PHP). The browser based UI for viewing profiler results makes it easy to view results or to share results with peers. A callgraph image view is also supported.

menu icons

Drupal : Add an icon to the menu links

We all like decorated items than normal ones. Everyone like to add icon/image to their site's menu links but we need some tricks to add that into our drupal site's menu link. I am going to show you various methods to add an icon/image to the drupal menu links.

1. theme_menu_link() : 

It would return html elements for the menu and it's submenu. We can change the menu html elements using this function and this function must be written in our theme's template.php file. In this example, I am going to add icons to the main menu.

Subscribe to Drupal