After seeing so many people complain about Drupal's theme engine and it's inflexibility, I decided to try for myself and convert an existing Nucleus theme to Drupal. I used bluemarine (phptemplate version) as a baseline.
Here's my experience:
1. Getting the basics done is pretty simple. It's easy to setup a container and set the global look and feel.
2. The problem is when I tried to theme items like navigation. I found that even ul and li styles are defined in a way not easy to change.
3. The biggest issues is when I tried to split out things like "date posted," "posted by," and "read more" (which I mentioned elsewhere.
4. I figured I would have to heavily edit the style.css but it turns out I had to edit page.tpl.php, node.tpl.php, block.tpl.php, and comment.tpl.php. That's pretty much each major theme file.
My Observations
I appreciate how simple it is to make global changes to the theme quickly but I'm left wondering why changing details deeply buried. I now see why most Drupal sites can be identified by the links line: print $links. I feel this should be split into separate functions: from a user perspective, comments and read more have nothing to do with one another. I would also like to see print $submitted opened up to allow for customized dates (like in the Stanch theme) and separating username from date posted. Again, it's not necessarily desirable to group these two items together.
I'm going to continue to modify this theme until I get it exactly like the Stanch theme. Unfortunately, by the time I'm done it looks like I will have modified several core files including some in the /modules and /includes directory. Once I'm finished I'll post the final theme if anyone is interested (with the caveat that once you upgrade from 4.6 it won't work anymore).
- Matthew
Comments
Look into...
... including a custom template.php file in your theme. That allows you to implement functions that override default behaviors lik the construction of the links array, etc.
Also, your node.tpl.php file has access to all the details of that node's data. $submitted is just a convenience variable that te PHPTemplate engine provides. If you want to build a custom info line for the node, variables like $node->created and so on are there for you to use. :)
--
Jeff Eaton | I heart Drupal.
--
Eaton — Partner at Autogram
Whatever you do
don't hack core files. You'll break your installation in the future.
I'm currently converting the theme of my site to a 4.7 PHPTemplate. Currently the theme is pure php. I find phptemplate to be very easy and flexible; to whomever wrote it: great job. I hope I can add my theme (a little spiced up) to drupal.org before 4.7 is released.
After reading your post I decided to see what other vars were available. $node->links is an array with all the links for the current node (add new comment, read more). The index for read more is not garanteed however; it depends on the amount of links. I'd like them more like array['read more'] = 'the link';
This is the ugly hack in node.tpl.php I've come up with:
Then when I'm at a point I want to print the read more link:
The rest of the links can be printed with a foreach or:
(You can combine this with http://drupal.org/node/16383)
CAVEAT: I've written this in the middle of the night (nearly 3am) and haven't thought of all the possible consequences nor tested it completely. One possible problem is that the remaining links are not always printed in the same order.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Change preg pattern
Better change the splitting to:
This makes it a little bit more robust. Note the ungreedy pattern modifier. If ommitted the entire string $item is matched.
Also change the printing of the other links to
Otherwise you will get an error when my_links is completely empty.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
How to do the same for other "links"
Hi Heine,
Can I use this method to move other items in links such as "times read"...
I tried using
But that didnt work, any suggestions?
Thanks in advance!
Ss
My php skills are well, not so good...
Similar for edit, delete, reply links in comment.tpl.php
In comment.tpl.php
This relies on no-one ever translating a link with a 'space|space' pattern.
Print the reply link:
To print the rest of the links:
add markup where necessary...
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Heine,
Heine,
You're the man! Thanks for looking into this. I will try your suggestions and post back this week. Thanks again!
- matthew | nautis.com
How to do this in 5.1?
Hi,
Heines solutions used to work like a charm with previous versions of Drupal. However, now that I'm building a website with 5.1 it seems like things have changed... Does anyone know how the code can be changed so that it will work with 5.1 too?
Thanks!
Marc
___________________
discover new oceans
lose sight of the shore
works with 5.1
jim
More about this snippet can
More about this snippet can be found at http://drupal.org/node/21538#comment-81773
SUbscribing for drupal 6,
SUbscribing for drupal 6, greetings, Martijn