[drupal-devel] [feature] modifcation to allow theme engines to theme all theme hooks

gordon drupal-devel at drupal.org
Wed Feb 2 04:54:21 UTC 2005


 Project:      Drupal
 Version:      cvs
 Component:    theme system
 Category:     feature requests
 Priority:     normal
 Assigned to:  gordon
 Reported by:  gordon
 Updated by:   gordon
 Status:       patch
 Attachment:   http://drupal.org/files/issues/phptemplate_1.patch (1.11 KB)

and the patch for phptemplate


gordon



Previous comments:
------------------------------------------------------------------------

January 30, 2005 - 08:31 : gordon

Attachment: http://drupal.org/files/issues/theme.inc_1.patch (889 bytes)

Attached is a patch that I would like to get into 4.6. I didn't realise
it but I am cutting this close.
What this patch does is give the ability to theme engines to be able to
handle all theme hooks with specifically having to code for them by
creating a function {theme engine}_{theme hook} (eg. phptemplate_pager)
What I have done to achieve this is I have created a new theme engine
hook called theme_handler. This will check to see if the current theme
has been set up to include this theme hook, and returns the function
that it should called to handle this theme hook. Most the time this
would most likely be a generic theme function.
This function is then called with exactly the same arguements as the
theme() was called with. (eg the theme hook as the first arguement) So
in the case of the pager the function is called like so

<?php
phptemplate_generic("pager", "", 10)
?>


The method that I have used, theme engines are not required to use this
functionality, as some theme engines such as I think xtemplate will not
be able to handle this, but it works extremely well in phptemplate.
The reason that I have made this modification is that i can use a theme
engine such as phptemplate to create the theme, and if I want to theme
any additional features such as pager, menu_tree, I can without having
to modify the theme engine from standard. So this gives me the best of
both worlds.
So with the phptemplate engine all I need to do to make use of the
additional functionality is add template file to the themes directly
like:- 
hook = hook.tpl.php, pager = pager.tpl.php, etc.
It also means in the case of the phptemplate engine the theme creaters
php skills can be limited, and still be able to expand the theme beyond
that of the engines capibilities.


------------------------------------------------------------------------

January 30, 2005 - 08:32 : gordon

Attachment: http://drupal.org/files/issues/phptemplate_0.patch (1.12 KB)

and here is the patch for the phptemplate engine to make use of this
functionality.


------------------------------------------------------------------------

January 31, 2005 - 03:10 : FactoryJoe at civicspacelabs.org

It seems to me that this functionality belongs in PHPTemplate and not
another theme engine.
Are there any possible security issues raised with using such an
open-ended patch?


------------------------------------------------------------------------

January 31, 2005 - 22:34 : Anonymous

This was part of my original design for the new theme systes, but was
removed because it was considered unneccesary complexity that only
affected phptemplate.
I think this is the right time to add it however, as it allows lots of
really creative things.
Also, most of the available template engines (smarty , phptal ,
phptemplate) are based on my original phptemplate code base, and as
such will benefit from this patch.


------------------------------------------------------------------------

January 31, 2005 - 22:48 : adrian

Bah. 
I wasn't logged in. 
Anyway, to answer joe's question .. this needs to be modified in core
so that phptemplate can leverage it. 
It really is only a small change in theme.inc.


------------------------------------------------------------------------

February 1, 2005 - 06:10 : gordon

Looking at the patch yes I do think there maybe a little security
concern. But I am not exactly sure of the best method to employ.
1. I could just return from the theme_handler a true/false and then
always call {theme engine}_generic and it can work it all out, which in
the case of phptemplate is all that it needs to call.
or
2. have the theme_handler return the hook, and then execute it as
{theme engine}_{hook} which does give you the added flexibility, but it
is not as much of a security issue.
Also as said before, we change to core is required so that hooks that
are not know by the theme engine have some way of being called.


------------------------------------------------------------------------

February 2, 2005 - 14:53 : gordon

Attachment: http://drupal.org/files/issues/theme.inc_2.patch (908 bytes)

I have made a change to the patch so that the process that is called is
called {theme engine}_{returned hook} which I feel is more secure, but
gives you more flexibility if the theme engine has the default handles
split up for ease of use.


-- 
View: http://drupal.org/node/16409
Edit: http://drupal.org/project/comments/add/16409





More information about the drupal-devel mailing list