You are hereDrupal / Drupal 7.x

Drupal 7.x


rahul's picture

Drupal - Defining plugins for Views Wizards

It has been the first time since I started blogging somewhere in 2009 that a full calendar month (of April 2012) passed without me writing any blog in that month. It feels good to be back to the blogging world.

rahul's picture

Drupal 7 - Handling file uploads and moving files to the public file system

This was the most time consuming aspect for the recent port of my Document module for Drupal 7.

You would be knowing that File system API underwent a complete revamp in Drupal 7 (see this and this link, a very good introduction of the changes and new concepts is available on Randy Fay's blog). In Drupal 6, handling file uploads was this easy:

 

rahul's picture

Drupal 7 - Creating arbitrary ANDed/ORed database queries using the DBTNG abstraction layer

While working on the 7.x port for my Document module for Drupal day before yesterday, I had a pretty anxious moment. As you would know, the new DBTNG database abstraction layer in Drupal 7 fundamentally changes the way your module code interacts with the db. Now instead of writing raw Sql queries, you use a set of high level objects to specify the various components of your query using a series of methods which is then translated to Sql by the DBTNG layer and executed against the database. Sample this for example:

 

rahul's picture

Drupal 7 - Controlling/Changing order of execution of particular hooks for modules

Drupal 7 brings some important API changes and enhancements to the table, one of them being the ability to control precisely the order of execution of a particular hook between modules.

I was asked by a client last week if it is possible to control execution of specific hooks between modules. Here is the (very precisely) framed question:

rahul's picture

Drupal and Chrome - Refused to execute a JavaScript script. Source code of script found within request

While editing content on a client site last week, I got a rather confusing error in Google Chrome Developer tools:

Refused to execute a JavaScript script. Source code of script found within request.

I was incorporating Google Maps on a page through a Block and the block content had some javascript code in it. But on saving the block, two issues surfaced: 1) I got the above error in Chrome Dev tools console and 2) The Map did not show up on the page.

rahul's picture

Ajax Sorted and Paged tables in Drupal 7

My recent blog post on Creating Paged and Sorted tables in Drupal 7 got a comment today asking if it was possible to implement Paging and Sorting in Drupal tables via Ajax, instead of regular Page refreshes that Drupal does by default.

rahul's picture

Drupal 7 - Creating Drupal style tables with paging, sorting and sticky headers

My earlier blog post on creating Drupal 6 tables (I mean html tables and not database tables) complete with paging, sorting, sticky headers and other Drupal table features attracts a decent number of visitors (Analytics tell me). So, I thought of publishing another post with the same theme but this time for Drupal 7, as there are significant changes on how you would create Html tables with Drupal 7 with all the features.

rahul's picture

Drupal - true "Save Draft" functionality for node forms by overriding node form validation

Let me clarify staright away that the code below has been tested successfully against Drupal 6 only. But I believe it should work with Drupal 7 also with minor changes (if any required). Okay now, let's come to the point.

rahul's picture

Drupal - node form validation methods in hook_form_alter should be set using #after_build to always execute on form submission

Last week, I was trying to add a custom validation method for node form of a particular content type in Drupal. My initial approach was as naive as specifying my custom validation method in hook_form_alter, something like the following:

 

function mymodule_form_alter(&$form, &$form_state, $form_id) {
	switch($form_id) {
		case 'artist_node_form':
$form['#validate'][] = '_mymodule_custom validation';
			break;
	}
}

rahul's picture

Drupal - Removing the default "-Select-" option from select form elements

I needed to remove the default "-None-"/"-Select-" option that Drupal's Form API adds to "select" form elements. Let's take an example. Consider the following "select" element definition for a form:

 

$element = array (
			'#type' => 'select',
			'#options' => array (
							1 => 'Very poor',
							2 => 'Not that bad',
							3 => 'Average',
							4 => 'Good',
							5 => 'Perfect',
						),
			'#required' => TRUE,
			'#title' => 'Rating',
		);

Recent comments