I have been readying the next version of PHPTemplate for the 4.6 release (the RC should be out very soon now). You can get this in CVS now, but it is NOT meant for 4.5. I am still undecided wether to back port it.

  1. Did away with the template caching. I did some benchmarking and it appears that file_exists() is nowhere near as heavy an overhead as I thought. This means you don't have to go to admin/themes to have the cache refresh.
  2. $seqid and $zebra variables are now available to all templates without needing to do the template.php hack (see: http://drupal.org/node/16383).
  3. $node object available in page.tpl.php on node view pages. This allows for some very creative layouts, and styling the entire page different for different node types (by adding a node-$node->type class to the body for instance).
  4. Automatic loading of node-$type.tpl.php files. You can create different templates for story / blog / etc. nodes. Practically, I still think CSS would be better for this, but it has been requested often, so here it is.
  5. Automatically uses a favicon.ico if found in the theme directory.

Unfortunately, the link configuration is still less than ideal. I am looking into a possible solution for that, but most methods actually involve breaking compatibility with xtemplate and by extension Drupal core.

Comments

freyquency’s picture

I'd like to get more out of 4.5 too since i'm in the midst of developing sites with drupal... but if it's not ready that's ok with me too. So how long till 4.6? ;)

this post brought to you by:
`':,..,:'``':,..,:'``':,..,:'``':,..,:'`
erik mallinson

adrian’s picture

so i'd recommend developing sites on that.
--
The future is so Bryght, I have to wear shades.

capmex’s picture

I will be using 4.6 to test the new phptemplate engine. Thanks
--
capmex.biz

Dublin Drupaller’s picture

hey Adrian,

Fair play to you...sounds exciting and the improvements you have outlined sound superb...

If you need a hand back porting it, give me a shout...if I'm given instructions on what needs to be changed I can help make it work for 4.5.0

Dub

DUBLIN DRUPALLER
___________________________________________________
A drupal user by chance and a dubliner by sheer luck.
Using Drupal to help build Artist & Band web communities.

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

adrian’s picture

After I fix a few bugs I found.

--
The future is so Bryght, I have to wear shades.

andremolnar’s picture

Awesome Stuff. Can't wait to try it out on a new theme or two without needing hacks.

Thank you so much for all your work on phpTemplate. I don't think its a coincidence that so many new themes have been developed since the introduction of phpTemplate - it has simply made themeing more accessible to the designers / casual coders.

And if its only getting easier (as it seems to be with this announcement) I'm sure the trend will continue.

Thanks again.

andre

sethcohn’s picture

With CivicSpace staying on 4.5 until after 4.6 is well out,
the number of 4.5 sites will remain quite large... and a lot of us would LOVE to use these features.

How much of a problem is the backport?

kbahey’s picture

Adrian

Just a big thank you for a very powerful and flexible engine. I ported the SpreadFireFox theme to 4.5 using phptemplate, and I love it.

I think it is time to make phptemplate part of Drupal core for 4.6. Xtemplate can stay as well, but let us include phptemplate engine, and one sample theme based on it (e.g. FriendsElectric).

As for backporting, I personally do not have this need, but if it is not a lot of work for you, then why not.
--

Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

adrian’s picture

The problem is the link configuration.

Until we can make the link configuration the same for all themes, we can't make phptemplate available in core.

This is one of the action points for 4.7 though.

--
The future is so Bryght, I have to wear shades.

clairem’s picture

Until we can make the link configuration the same for all themes, we can't make phptemplate available in core.

One of PHPtemplate's deficiencies is its link configuration. By not allowing attributes for the links, there is no way of using to provide accesskeys or titles for the links, both of which are very important for accessibility.

As a result, I have given up using PHPtemplate, because I know that I'll eventually have to implement them as to a full theme if I want to maintain accessibility.

I hope that this gets attention if PHPtemplate is to be moved into the core

Max Bell’s picture

I'm not following this. What's to prevent you from defining your XHTML attributes in the configuration section of themes when you add the links, themselves?

clairem’s picture

Max, the problem arises from the way that PHP template doesn't allow freeform HTML for primary and secondary links, as Xtemplate does.

Instead, it requires that links be entered in a specific format which allows only for URL and link text, which are then used to construct the link.

So if you enter

Jane's blog:/blogs/jane;

the link will be generated as

<a href="/blogs/jane">Jane's blog</a>

I think that in general, this is a very sound approach -- I don't think site admins should have to enter raw XHTML. But the syntax needs to be richer, to allow further attributes.

For a theme I am developing, I have created a custom syntax of

link text//link title attribute//accesskey::link url;;

... and while that's a little crude, something with that sort of flexibility is needed if raw XHTML isn't available

jmlane’s picture

Untrue, you can do the same in PHPtemplate, mind you, it took me a while (not to mention getting help from the primary developer of PHPtemplate) to figure out how do so. Read this article, I posted the solution incase anyone else was looking to do the same thing as myself: Rewriting primary links XHTML.

Cheers,

Jonathan

clairem’s picture

Jonathan, well done finding a workaround alright, but it's a limited one, and rather unfriendly for the admin.

First, it requires the user to go off and instal a dose of PHP ... and second, it only seems to allow attributes that are hardcoded in the PHP.

I just want something that a less techical adminstrator can use, someone who knows XHTML but not PHP. It was very easy to create an input syntax which allowed that, and it's much better to have it configured through a menu interface than in the midst of a PHP file

adrian’s picture

It no longer requires an input format.

That still doesn't mean you can do accesskeys though.

--
The future is so Bryght, I have to wear shades.

gordon’s picture

The link configuration in all theme engines in pretty bad. I have actually been able to use the menu.module to handle my Primary and Secondary menus. I am still in the process of writting up an how to so that other people can do it.

Here is a link to the howto which is still incomplete but has the php code from my phptemplate theme. It doesn't have the css, but I could post that.
--
Gordon Heydon
Heydon Consulting

--
Gordon Heydon

adrian’s picture

http://drupal.org/node/18575

--
The future is so Bryght, I have to wear shades.

gordon’s picture

Basically I feel that the current method of handling the primary and secondary menus is extremely poor, considering how good the menu.module is.

There are some gotchas in my plan such as if the user puts in a multi level menu like the navigation menu then it will fall over in the display, but if you have a dhtml menu like phplayersmenu to render then you can have multi level menus that work very well, and are very easy to administer.
--
Gordon Heydon
Heydon Consulting

--
Gordon Heydon

travischristopher’s picture

Nice two layer tabbed menus, check this one out.

~Drupal gets better every day

Travis Christopher
http://www.fame4art.com

Mateo’s picture

I've spent the last few days hacking away at code that would easily be taken care of with the modifications you just mentioned. I don't plan on upgrading to 4.6 as I havn't kept very good track of my modifications (and I dont' want to do them all over again).

Mateo

crackerjackmack’s picture

Try using diff. I have heard there is a windows version as well

diff -u -f^F oldfile newfile

Mateo’s picture

I tried to splice in the one function I really want (_phptemplate_default) into my old engine. I'm still running 4.5.2 and I mainly want the functionality of multiple template files.

After I replace the old function with the one found in the CVS version, all that I get is the following error message: PHPTemplate was instructed to override the theme function, but no valid template file was found

So with that I'll be going back to the old engine and having a massive node.tpl.php file until I can figure it out.

Mateo

jmlane’s picture

Hey Adrian,

Great work on the PHPtemplate engine! I'm sure you hear this many a times, but all the hard work you and the rest of the Drupal devs put into this project makes this CMS one of the best I've come across. The flexibility of Drupal is very impressive and your work with PHPtemplate makes it all that much more flexible when it comes to the visual aspects of it.

As for the node-$type.tpl.php files, I realise a lot of the customizations can be done with CSS, because most of mine are. However, sometimes you need to add an additional Classed or IDed element into your XHTML to display things the way you want. And will there be a $node->type for admin nodes? That's something I've been hoping to see.

Good luck,

Jonathan

adrian’s picture

I noticed that seqid / zebra were working for all blocks, in sequence.

IE: if you had 3 blocks on the left, and 4 on the right, the seqid of the first block on the right would be 4, and it's zebra would be even.

Hence I implemented extra handling so that you now have the values block_seqid and block_zebra, which counts each of the sidebars seperately.

I'm gonna try to back port the new functionality a bit later.

--
The future is so Bryght, I have to wear shades.

media girl’s picture

Any plans to incorporate taxonomy_images support? As it is, several hacks are required.
--
mediagirl.org

paddy_deburca’s picture

The taxonomy_images help add a bit of imagery to websites.

It would be nice if the hacking was included in the template.

Paddy.

http://deburca.org and http://amadain.net

sethcohn’s picture

So long as you're making a hack-free version for general use, adding taxonomy_images support makes sense. The overhead is minimal.

harald.walker’s picture

I have also been using a modified version of the phptemplate.engine until now (23 lines of code in the phptemplate_page function), but looking at the examples on http://drupal.org/node/16383 I am wondering, if the taxonomy_image variable can't be defined in template.php instead.

adrian’s picture

I am not going to specifically support any additional contrib modules in phptemplate, but you are able to add support for them yourself, without needing to modify the engine.

The _phptemplate_variables() function is your friend.

--
The future is so Bryght, I have to wear shades.

media girl’s picture

As for myself, I don't understand what phptemplate_variables() function is. All I know is that the only way I found here to be able to add taxonomy_images was to hack the engine and themes, and I could only do that because of some by-the-numbers instructions on a couple of threads here.

If there is another, better way, perhaps someone could share it? I, too, would rather not have to go a-hacking with every upgrade. (Maybe such extra info/files could be included with the taxonomy_image module?)

--
mediagirl.org

adrian’s picture

http://drupal.org/node/16383

I'll play with the taxonomy_image module some time and add an example there.

--
The future is so Bryght, I have to wear shades.

yelvington’s picture

If all pages had a node type, this would solve many problems for me ... unfortunately $node->type is null on many pages, such as the blogs overview page and integrated gallery2 pages. :-(

Anything else I can use to detect page types?

What I'm really trying to do is drop all right blocks on gallery pages.

gordon’s picture

On pages that have no nodes or many nodes the $node object is not passed thru.

What you could do is look at the node cache and get it from there.

global $node_cache;
$node = $node_cache[0];

This will always get the first node on the page.
--
Gordon Heydon
Heydon Consulting

--
Gordon Heydon

yelvington’s picture

That helped a bunch. There still are some pages of mystery types, where even the node cache is null, but the aggregation pages (which were my primary concern) are non-null.

Testing $node_cache[0] enabled me to rewrite my template so that the right blocks are restored on most pages but omitted from Gallery2 embeds (and a couple of others where the omission is not an issue).

phptemplate rocks.

adrian’s picture

I should change it to always pass the nodes?

Node pages was a special case I had seen requested often.

--
The future is so Bryght, I have to wear shades.

Max Bell’s picture

I've learned so much using Drupal.

PHPTemplate provided the impetus to learn CSS. Learning CSS provided the impetus to learn how to move some of the PHP around in the boxgrey examples provided in the documentation. Eventually I learned how to style new elements by checking the generated HTML in firefox.

I spent most of my (exceptionally limited) time between 4.5 and the current RC learning how to (at last) create a proper theme. If I had more design sense than the average household appliance, I might even have something to post to contrib.

But the point is that PHPTemplate is one of the coolest things about Drupal right now. Kind of gets you over the "take someone else's theme and mod it" hump, if you don't know what you're doing the rest of the time. I'm not much of a mailing-list guy (I hail from the BBS era; I post to forums ;) but I've been following the development of this since you posted about the design process in the beginning.

I certainly owe you a tip of the hat for writing it, Adrian; I've had a lot of fun playing with it and look forward to future developments.

Mateo’s picture

This is back ported yet to 4.5.2?

carlmcdade’s picture

Probably of topic and more of a wishlist item but is there anything in the new functions that can be used to control the number of blocks?

I am working on horizontal display of blocks and right now I am marking the the box.tpl and then doing a split on page.tpl to get them into an array and iterating through them to get the right number and regexs to find the right ones.

It would be nice if there was a choice between a string or an array so that one could do:

$sidebar_left

or

$sidebar_left_arr[0],$sidebar_left_arr[2],$sidebar_left_arr[4]

or is this something that is controlled by Drupal?

---------------------------
www.hivemindz.com (running PHP5)
www.fireorb.org (documentation and hacks)
__________________________
Carl McDade
Information Technology Consult
Team Macromedia

iraszl’s picture

That was quick! Thank you!
Where can I learn more about how to make templates?
I know CSS and I can modify an existing theme quite a bit, but I'd like to write a theme from zero. What do I need to know to be able to do that?
Thank you!
---
http://creativebits.org

freyquency’s picture

it's all php to me.
i'd start out with the basics of php and then come back to drupal. I did that and it made me very much respect the clean, efficient code they use here. if you already know php, then it's a matter of picking a template engine that has a coding style you like and going with it. check out different themes that use a template engine (phptemplate for example) and peep em. i'd also take a look at http://drupaldocs.org as you can customize phptemplate quite extensively so you'll find the things here you can alter... and it's good for info on what's happening in drupal's core.

also check the template documentation on this site, and search the site when you have a specific request. most of the stuff done with the current versions was built on lots of community feedback and brainstorming. one more thing - try searching for sites that aren't drupal as a lot of the people here maintain their own sites and have blog posts about what they are interested in. I for one try to keep up on quite a few people here who have the same goals in mind (dublin drupaller , rob from robshouse, and carl for example.)

this post brought to you by:
`':,..,:'``':,..,:'``':,..,:'``':,..,:'`
erik mallinson

Steven’s picture

I gave a quick overview of making FriendsElectric in my drupalcon presentation. I still need to write that out longer and with more images, but it gives you an idea.

--
If you have a problem, please search before posting a question.

adrian’s picture

Sorry it took so long guys. But the 4.5 back port is finished. It should take a day or so to update the tarball, but it is in cvs now.

--
The future is so Bryght, I have to wear shades.

carlmcdade’s picture

The back port use a 4.6 function system_listing() not present in 4.5.2. But it is nice. One thing I noticed is that the sections with custom templates render faster than those using the generic template for nodes.

function system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
  $config = conf_init();
  $searchdir = array($directory);
  $files = array();

  if (file_exists("$config/$directory")) {
    $searchdir[] = "$config/$directory";
  }

  // Get current list of items
  foreach ($searchdir as $dir) {
    $files = array_merge($files, file_scan_directory($dir, $mask, array('.', '..', 'CVS'), 0, TRUE, $key, $min_depth));
  }

  return $files;
} 

---------------------------
Hivemindz CMSopdedia
__________________________
Carl McDade
Information Technology Consult
Team Macromedia

mariagwyn’s picture

I am currently setting up a site in 4.5 (can't do 4.6 until images etc., are ready) and my own in 4.6. The "node-$node->type class" function sounds like it is exactly what I need. I have already downloaded the backported cvs file for 4.5. What I would like to do is be able to take a module I modified ('jarticle') and be able to output the code so it looks like this:
"<div id/class="node-jarticle">" so that the node can then be complete styled by css. I am assuming that is what #3 is about. Unfortunately, as a designer not a coder, I am at a loss as to how to do it.

Would some kind and patient soul be so good as to explain how do this? I am happy to hack a file, or add code somewhere, whether the phptemplate engine itself, or create a new tpl.php file. I can also copy and modify another file. What I am very confused about is how I tell the engine to take note of the special name of my node, and then how to find the correct tpl.php file. So, a brief step-by-step would be very helpful.

Thank you ahead of time for the your help!

If you need to see the sites, they are:
http://www.stnina.org/test/node (the front page is still being adjusted) or
http://www.mariagwyn.com/dpl/node (front page still being adjusted too...)

Maria

gordon’s picture

Basically because the $node object is now avaiable to page.tpl.php you can instead of having :-

<div id="node">

you can have

<div id="node-<?php echo $node->type ?>">

which will create the node-jarticle.
--
Gordon Heydon
Heydon Consulting

--
Gordon Heydon

mariagwyn’s picture

Thanks. I will try that when I have a chance.
Maria

hex1848’s picture

Administer > Themes > Box Grey > Settings

I am running the 4.5 version of Box Grey and I cant seem to configure the settings for the template. All I get is a blank page. The Box Grey CSV doesnt look like its had any updates in a while.

Does anyone have a working theme for Drupal 4.6 RC and phptemplate 4.6?

gdip’s picture

I found the Bio theme (http://bssteph.irtonline.org/bio_drupal_theme_for_phptemplate) that seems to work with the most recent cvs version of phpTemplate (for 4.6).

iraszl’s picture

Is phptemplate for Drupal 4.6 available for download yet? Just want to try it out. Thank you!
---
http://creativebits.org

kbahey’s picture

The CVS tarball should work well with 4.6RC.

http://drupal.org/node/12457/release
--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

iraszl’s picture

Thanks bro!
---
http://creativebits.org

iraszl’s picture

Do you know if there are any themes working with the cvs release?
---
http://creativebits.org

kbahey’s picture

I tested a few themes, and they seem to work fine (apart from known issues particular to those themes, such as the white space issue).

The themes I tested are the CVS versions of Democratica, Lincoln's Revenge and SpreadFireFox. I also think that FriendsElectric does work.

My testing was not extensive, since it was focused on porting those themes from 4.4. to 4.5 and 4.6, but I did not look for specific problems with css and such.
--
Consulting: 2bits.com
Personal: Baheyeldin.com

--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba

iraszl’s picture

Ah, ok thx! Great news! I thought all themes will need updating.
---
http://creativebits.org

freyquency’s picture

I was having some weirdness with 4.6RC and phptemplate cvs. The primary and secondary links fields were showing up in the configure sections as the non-phptemplate variety (textbox) and not displaying at all on the site. The same thing was happening with the mission statement as well. Apparently it needs to be deslected, saved, and reselected for it to appear correctly. I'm not sure if it's a browser caching thing or what, but in case anyone else has that problem I thought i'd post a possible solution.