Drupal theming for designers, continued.

Drupal Theming – Part 2 – Controlling themes

This is a continuation of the earlier article on Drupal theming for designers.

Near the end of the previous article, we mentioned other *.tpl.php files used by themes. These files, and any others that you create, using Drupal’s PHPTemplate file naming convention, you are able to ‘override’ the default display:

  • node.tpl.php
  • block.tpl.php
  • box.tpl.php
  • comment.tpl.php

Drupal’s PHPTemplate theme engine uses the content generated by these files in page.tpl.php, as the following diagram demonstrates:

More control means more power

Using the *.tpl.php you can control:

  • the display of different content types, such as blogs, forum posts, or anything else you create. What are 'content types' (node-[content type].tpl.php)
  • the display of content in edit-mode (node-edit.tpl.php)
  • the display of individual nodesWhat is a 'node' (node-[node ID number].tpl.php)
  • the display of the front page

Controlling the content being passed to the *.tpl.php using variables

Let’s look at the variables used in page.tpl.php and node.tpl.php:


Here, we see page.tpl.php prints variables such as $sidebar_left and $mission.


In node.tpl.php we see variables such as $sticky.

You can use template.php to override functions returning these variables and you can intercept other variables:

This template.php example, from the Zen theme, demonstrates function overrides:

  • zen_regions
  • zen_breadcrumb

Here is the documentation listing all themable functions: http://api.drupal.org/api/group/themeable/5

A brief note regarding regions

It also demonstrates variable re-definition, which is scope controlled:

  • $vars[variablename]

Here is documentation listing all variables available in page.tpl.php, node.tpl.php, and block.tpl.php.

For more on creating Drupal themes, I recommend the following:

Comments

As great as part 1. This is the most useful tutorial for the beginners to design their own themes.

Guest (not verified) | Thu, 07/10/2008 - 12:40 |

Can these themes be implemented on something else and not a Drupal template?

Guest (not verified) | Wed, 07/02/2008 - 06:10 |

Good day! This post could not be written any better! Reading this post reminds me of my good old room mate!
He always kept talking about this. I will forward this post
to him. Fairly certain he will have a good read. Many thanks
for sharing!

http://www.reddit.com/r/mysidekick/related/2psklk/new_fun_ (not verified) | Sat, 12/20/2014 - 02:01 |

I've been surfing online more than three hours today,
but I never found any fascinating article like yours.
It's beautiful price enough for me. Personally, if all web owners and bloggers made excellent content as you did, the web will likely be much more useful than ever before.

http://www.reddit.com/r/cheatsmania/related/2pir7o/reddit_ (not verified) | Wed, 12/17/2014 - 15:14 |

you're in reality a just right webmaster. The site loading velocity is incredible.

It kind of feels that you are doing any unique trick. Furthermore,
The contents are masterpiece. you've performed a wonderful job on this matter!

http://www.reddit.com/r/cheatsmania/related/2pit0f/online_ (not verified) | Wed, 12/17/2014 - 14:26 |

It is perfect time to make a few plans forr the longer term and it is time to be happy.
I've read this put up and if I could I want tto counsel yoou some interesting issues or tips.

Maybe you could write next articles referring to this article.

I want to learn more things approximately it!

clash of clans hacks (not verified) | Sun, 12/21/2014 - 01:09 |

You could certainly see your enthusiasm in the
article you write. The sector hopes for even more passionate
writers such as you who aren't afraid to mention how they believe.
At all times go after your heart.

https://www.reddit.com/r/killshothackonline/related/2pkqsv/ (not verified) | Thu, 12/18/2014 - 00:22 |

WOW just what I was looking for. Came here by searching for 8 ball pool hack bot

http://www.reddit.com/r/mysidekick/related/2potq3/free_8_ (not verified) | Fri, 12/19/2014 - 02:24 |

Good way of telling, and pleasant paragraph to take data on the topic of my presentation subject, which i am going to deliver in academy.

http://www.reddit.com/r/cheatsmania/related/2ovgt6/ (not verified) | Wed, 12/17/2014 - 14:41 |

Islamorada tarpon fishing involves the fishing of an prehistoric rare fish tarpon through the scientific name Magalops Atlanticus which is a prehistoric
fish considered to be one in every of the diverse & interesting creatures across the
country which can be present in both side of Atlantic also referred
to as as the tarpum tarpon or else the silver king due to it's majestic appearance & colour which
lays 15 million eggs. If you like antiques you have to ask for help- we have many but
only the locals know where they hide. If you are a foreigner unlikely to return if allowed
to leave, you will not be able to post a
bond.

deck plans celebrity summit (not verified) | Sat, 12/20/2014 - 17:28 |

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options