You are hereOpen Source CMS / Drupal / Drupal 5 Themes
Drupal 5 Themes
Packt Publishing today announced the release of my newest title - Drupal 5 Themes.
As the Packt site explains:
Create a new theme for your Drupal website with a clean layout and powerful CSS styling.
- Learn to create new Drupal 5 Themes
- No experience of Drupal 5 theming required
- Set up and configure themes
- Understand Drupal 5's themeable functions
- Finding your way around Drupal 5's theming architecture
- Locating and identifying the various elements, functions, and styles
- Working with the PHPTemplate templating engine
- Intercepting and overriding default templates and styles
Expected December 2007. Pre-order now!
I think most Drupal fans will find the book of interest. Not only did we explain step-by-step the key functions, but we also documented all the (20+) style sheets and all the themeable functions. It's our hope that even more experienced Drupal developers will find the resources contained in the book to be useful.
In typical Packt style -- 5% of all profits goes back to the Drupal Foundation.
p.s.
In case you had been wondering where I had disappeared to these last few weeks/months -- now you know!



In 5.x, Drupal modules saw the introduction of .info files to store meta data about the module (for example, the name, description, version, dependencies, etc.). Starting in 6.x, Drupal themes also have a .info file. See the complete guide to writing .info files for themes for more information.
Example themeName.info (partial list.):
name = Theme Name
description = One sentence description of theme.
core = 6.x
engine = phptemplate
Theme registry
All theme functions must now be registered. In Drupal 5, they were all discovered on the fly. New in 6.x, hook_theme() is used to register all themable output. PHPTemplate engine takes care of registering on behalf of the theme so in most situations you will not have to register manually.
There is one exception to this. Forms that do not have a default theme implementation will not be registered.
See the example in the theming handbooks for more details on theming forms.
Important note! Whenever you add a new theme function or template inside your theme the registry must be cleared!
Theming through template files
In 5.x, themable functions could be overridden with "themeEngine_hook()" or "themeName_hook()". All the markup could be placed inside the "template.php" file and returned with the data.
To go even further and allow the theme function to use separate template files (.tpl.php), _phptemplate_callback() could be used. Enabling the callback also allowed the hook to manipulate the variables with the following.
The following is no longer supported:
<?php
function _phptemplate_variables($hook, $variables) {
switch ($hook) {
case 'page':
// process variables for page hook.
break;
case 'node':
// process variables for node hook.
break;
}
return $variables;
}
?>
In 6.x, _phptemplate_callback() is no longer supported. It has been rolled in to the main theme() function. As long as the function is registered as a template, the template file will be used. _phptemplate_variables() has also been deprecated.
Registering as a normal function works just like overridding with "themeEngine_hook()" or "themeName_hook()" without the callback in 5.x.
PHPTemplate automatically registers the hook as a normal function or template. To register the function as a template, all you need to do is create a file named after the hook followed by ".tpl.php". For example, the hook "menu_tree" is themable so, create a template file inside your theme named "menu-tree.tpl.php". Note the underscore being changed into a hyphen. Clear the registry and it will take over.
More details on the overriding behavior is available.
You can take a look at the underlying changes between 5 and 6. –links to pdfs
Template management
Template files (.tpl.php) can now be managed more easily by organising them through sub-directories. PHPTemplate engine will find all files in the theme and register thier locations. There is no limit on its depth either.
New template files (.tpl.php)
In 5.x the following templates are implemented by phptemplate.engine (inside the theme engines folder):
page.tpl.php
node.tpl.php
comment.tpl.php
block.tpl.php
box.tpl.php
With the new changes under the hood, more default templates are provided and more will be available in future releases. The ones from PHPTemplate in 5.x were also moved. Read the comments inside these files to see where they are used and the available variables.
In order to override these templates, all you need to do is copy them into your theme folder and clear the theme registry.
See the complete list of new templates in the theming handbook.
The seldom used default core functions for the above templates are no longer present. For example, theme_page no longer exists. This affects all themable output converted into templates. Due to the nature of the change, they are no longer necessary. This change should not affect anyone. Do not confuse the removed functions with how they are called. theme('page') still works. It is the default implementation that has changed.
Alimentacion
Actually, I found the book very helpful.
Here's my review.
I hope there's more to come!
Cheers,
Marc Robinsone
I'm enjoying the book, but a bit disappointed about my timing. the current zen theme is totally different from the one described in the book and even though I installed the themeing api and selected "fixed" width, as someone suggested to me, the css files are very different and i'm having a hard time following chapter 6. I'm hoping there might be some suggestions - I am still learning quite a lot, but my thinking is quite concrete and I was trying to follow it exactly.
I am sure you're not the only person experiencing this problem. As we note in the book, the Zen theme is under active development and it has been changing -- particularly in anticipation of the Drupal 6 release. The publisher vetoed including the full code in the title, hence only parts of it are in there and hence, indirectly, this problem. In hindsight, I probably sd have pushed for them to include a snapshot of the Zen theme as it was at the time of writing, but that does little good now.
Try dropping me a line on the contact form on this site -- referencing this note. I will dig through my files and see if I have a dnapshot of the theme as it existed at writing.
Sorry for the hassles!
I'm not sure this is for me but please be candid.Can I install and design Drupral Themes from a Mac? I’m a newbe and can use all the help I can get. I’m now using a nice little slide show program called slideshowPro_director. It’s a server dependent product. So the reason I mentioned it I had to have my server set up a data base before I could install it. Is this the same with yours. So Can I incorporate this with Flash since slideshowPro is sort of a flash dependent product. What I mean is you have this small .xml file you create which was a first for me and ssp is a Flash Extension. As you cna tell I'm not a coder but willing to learn. Can I use this with Dreamweaver and Flash?
I built this site on a Mac and keep my development aserver on a Mac. There are no Mac-specific issues when it comes to working with Drupal (fyi - I have MAMP installed, which is a very easy way to get all the various bits and bobs you need for the LAMP stack in one neat package. Visit www.apachefriends.org for the free download).
As for the other applications you mention, I have no experience with them. Given that Drupal has a very open framework, I wd expect that they work fine, but they may require someone to do some integration. You sd look, however, you may find it has already been done and is available through the community. If you can't find anything in the Modules section of the Drupal site, just post a note for the Forum.
Good luck!
http://dreamweaverdrupalthemeextension.blogspot.com/2008/01/drupal-5-the...
did the pact pub inform you the final date of release?
I have been informed that the text is now at the printer. Don't know when the copies will ship but production is under way.
Happy Holidays everyone!
I have the final proofs in my hands right now. FYI - Packt uses on-demaind printing so they are able to physically produce the books very very quickly (this is an interesting topic in itself, but I digress...). They are telling me it will be this month, but I expect the actual date is still up in the air until the proofs are approved.
Will post when I have an announcement.
Post new comment