Skip directly to content

Welcome to my personal website. I am Sivaji a web developer from Chennai with 2+ years experience in Drupal.

sivaji's picture

How to Prevent PHP notices logging to watchdog

on August 14th, 2011 at 12:42:14 PM

dblog is one of the handy features of Drupal. It's a core module that monitors your system, capturing system events to database (or to *nix syslog with syslog module). This is useful for site administrators who want a quick overview of activities on their site. It also records the PHP warnings and notices. Notices are often trivial and they could be ignored from logging, IMO.

While it is essential to keep your Drupal site free from throwing any PHP notices, but in the current trend where most of the Drupal 7 modules are in beta / pre-beta stage it has been hard to ensure.

I figured out that

sivaji's picture

Six reasons to avoid using PHP input format in Drupal nodes and blocks

on August 9th, 2011 at 10:44:47 PM
  • Code in your database can not be version controlled and is also harder to find in general later on.
  • Eval()'d code is much slower than something hardcoded in a file.
  • If there is an error somewhere in that code, you will get a very unhelpful error message (error in eval()'d code at line 3) and you might even have go through your database manually to find and fix the error. If it is inside a block that is displayed on all pages and results in a fatal error all the time for example.
  • The above is also true when upgrading from Drupal 6 to 7 and whatever API's you used were changed.
sivaji's picture

When to use files[] directive in module's info file

on August 8th, 2011 at 1:15:59 AM

Drupal modules are the ways to extend (or alter) Drupal's functionality. Modules convey their presence and metadata through an .info file (aka info file or dot info file). Info files defines a set of directives (or properties) that conveys module's name, purpose, compatibility with Druapl version, dependencies, PHP version requirement, etc. to Drupal.

Drupal handbook page Writing .info files (Drupal 7.x) says

Drupal uses .info files (aka, "dot info files") to store metadata about themes and modules.

For modules, the .info file is used for:

  • rendering information on the Drupal Web GUI
sivaji's picture

Beware of hook_requirements() usage

on July 24th, 2011 at 5:53:07 PM

hook_requirements() is a handy Drupal hook exists since 5.x. It helps to check the file permission, availability of external library or any prerequisites essential for a module before enabling it. See API doc. As mentioned in the API doc hook_requirements() can be triggered in different context. It is identified using $phase argument. It is better not to count on Drupal API like t(), l(), url(), etc. here as they could be unavailable when involved in phase "install".

I stumped upon an interesting bug with robotstxt module when I tried to enable it along Drupal core installation from a custom

sivaji's picture

How to disable views programmatically when the offering module is disabled

on July 23rd, 2011 at 1:29:52 PM

I came across this case recently. I maintain the tiny module - uiplog which logs the IP address, user id and login timestamp of Drupal site users on login event. The logged details are exposed in a page using views module hook_view_data(). When the uiplog module is disabled the views offered by the module remains active and when the views page is accessed it throws PHP notices and warnings. I was wondering to fix it. After a bit of research I came up with the following snippet to disble views on disabling the module using hook_disable(),

  1. /**
  2.  * Implements hook_disable()
  3.  */
  4. function
sivaji's picture

how to programmatically change field instance properties

on June 19th, 2011 at 11:47:28 AM

Everyone is aware that CCK has been introduced into Drupal 7 core in the name of Field.  A field can be attached to one or more content types (or any Drupal entities). When it is attached it is called as Instance. A field instance can have different properties across the entities and it is configurable from Field UI admin interface. Also it is possible to change from module hook_install() or so with API calls. Recently I had to do this as a part of quiz 7.x module development. Quiz module utilizes the benefit of node system where body field is used to store questions/instructions.

sivaji's picture

Quiz module for Drupal 7

on June 12th, 2011 at 11:58:57 PM

Quiz module has a very long history in the Drupal community. In fact it was one of the oldest projects in Drupal ecosystem. Some of its earlier committers are in very responsible position in Drupal community now. From my inference, in the recent times, I would say it is not far away from getting a place of its own in drupal abandoned modules list, given that we have 2663 recognized installations as of writing this blog post. It has been several months since Drupal 7 was officially released but the community has seldom felt the need of this module.

sivaji's picture

Adding Tweets to Drupal site (without twitter module)

on June 11th, 2011 at 9:20:16 PM

Recently I found one of the simple ways to display tweets in blocks / pages in Drupal sites. I would like to share the same in this blog post. Twitter.com is exposing users tweets as RSS feed from identified URLs like https://twitter.com/statuses/user_timeline/[TWITTER-NAME].rss, for instance my twitter name is @sivaji_ganesh and I would be able to access my tweets from URL https://twitter.com/statuses/user_timeline/sivaji_ganesh.rss.

sivaji's picture

How to remove not verified string from user comment

on May 23rd, 2011 at 10:42:35 AM

Drupal appends "not verified" string to user's comment as below,

Not sure why it does so nor I am aware of making a comment as verified but the following trick worked for me to remove it.

Click the theme "settings" link in theme manager page.

In the "Toggle Display" settings uncheck "User verification status in comments" option.

This will work only for standard drupal installation, for drupalgardens site the theme manager page is different and there is no clean way of doing it. Check http://www.drupalgardens.com/content/remove-not-verified-text-comment for workarounds.

Thanks to tuxnani

sivaji's picture

Hacked user import module for content profile tokens

on May 17th, 2011 at 10:52:02 PM

Recent we had to import a few thousands of users from our third party sites. The users details were available in a CSV file. We felt that user_import module was pretty much aligned to our requirement and the module does more than what we would infer from its name. A quick list of features that the module provides can be found in its project page at drupal.org. However one place where we felt the user_import was lacking is the enhanced support for token integration.

Every user account in our site has been associated to a content profile node. And the CCK fields of node has been mapped to user's

Pages