hook_theme doesn’t get called

I was developing a new module in drupal and it needed a theme function to be implemented.

As per the instructions, it was implemented as follows (to use a template)

/**
 * Implementation of hook_theme().
 */
function my_module_results_theme($existing, $type, $theme, $path) {

	return array(
    	'my_block' => array(
    		'template' => 'my_block',
	 		'arguments' => array(
				'var1' => NULL
			)
		)
	);
}

However, when trying to apply the theme, it didn’t work. I tried various things and identified that the hook above was just not being called. A little bit of digging helped me discover that themes are cached. This happens even in the dev mode. To resolve this, go to

Administer  -> Performance -> Clear Cached Data (right at the bottom of the page)

and et voila my theme was now being utilised.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s