Submitted by madmatter23 on Thu, 08/18/2011 - 09:17
This one is a little bit more esoteric. I found the need change the page style (via CSS) based on whether the current user had permission to update the current node. Drupal preprocess_page to the rescue!
Just add this snippet to the yourTheme_preprocess_page function in your template.php file. It will add body classes (e.g., user-node-update, user-node-delete) to your page depending on the current user's permission to access the node being viewed.
Submitted by madmatter23 on Thu, 08/18/2011 - 08:49
If you'd like to change your site's appearance based on the current user's role, you can easily add the current user's role to the $body_classes array.
Just add this snippet to the yourTheme_preprocess_page function in your template.php file.
Drupal 6:
Submitted by madmatter23 on Mon, 08/15/2011 - 14:45
Drupal has a standard array of template suggestions that let you specify which TPL file should be used according to node type, node id, etc. However, there is no default template suggestion for pages generated by Panels.
You can easily fix that by adding a little snippet to your template.php files' preprocess_page() function.
Submitted by madmatter23 on Wed, 06/08/2011 - 07:35
Drupal's ability to preprocess HTML code in your theme's template.php file is extremely helpful for theme coding and site administration.You can find excellent preprocessing scripts on Drupal.org's forums, or simply use one of the many free Starter Theme such as Zen or Basic. I personally use the Basic Theme, which does quite a lot of theming work for you.
As great as Basic theme's template.php file is, there's still room for improvement. I've added four major improvements to it here:
Recent comments