Tag Archives: Drupal Development

Drupal – Customized the User Registration Form

For the Drupal registration form, there is no .tpl.php template file for editing the registration form layout. So if you want to add more HTML code around the form, you have to do it on code level.

I found a useful post about modifying the registration form. It make use of the template.php in the theme folder to theme the form. For more information. Please visit Drupal – Custom registration page theme.

In this post, i will modify the registration form by creating a custom module. Continue reading Drupal – Customized the User Registration Form

Drupal – Define Your Own Cron Job

How does the cron job in Drupal work? Let’s take a look.
cron.php

<?php
// $Id: cron.php,v 1.36 2006/08/09 07:42:55 dries Exp $

/**
 * @file
 * Handles incoming requests to fire off regularly-scheduled tasks (cron jobs).
 */

include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_cron_run();

 

Looks simple, right? the drupal_cron_run() function will run the default Drupal cron tasks as well as invoking the hook_cron() in all modules. Continue reading Drupal – Define Your Own Cron Job

Drupal – Add Task to the Drupal Cron Job

Drupal has a cron.php at the root directory. you can run the this cron job by either entering the http://<drupal_root>/cron.php in browser or running it directly in the Drupal status report.

The default Drupal cron job cleans up log files and checks for Drupal and modules updates. If you want this cron job to be run at a regular interval, just edit the crontab by the following command.

  • crontab -e

 

and add one of the following lines with you desired interval. (45 mins in the following example) Continue reading Drupal – Add Task to the Drupal Cron Job

Drupal – Get URL Arguments in Custom module or Views Template

You can get the URL arguments in custom module or views template files. Create a custom module and use the hook_nodeapi to print the URL arguments.

/**
 * Implementation of hook_nodeapi()
 */
function custom_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      print arg(0);
      print "<br/>";
      print arg(1);
      break;
    }
}

Continue reading Drupal – Get URL Arguments in Custom module or Views Template