[support] Overriding page.tpl.php for node type...

John Callahan john.callahan at UDel.Edu
Fri Apr 10 15:40:20 UTC 2009


It is my understanding that 'out of the box' Drupal does NOT use a 
template suggestion for page templates based on content type.  Page 
templates are overridden by default for the front page or specific nodes 
only.  Node templates CAN be used per content type by default (node 
template are not what you're asking about.)  Plenty of information on 
http://drupal.org/node/190815 (as already mentioned in this thread.)


To use a page template per content type, I believe you will need to use 
a custom function in template.php.  The one provided by Aldo seems like 
it should work.   It could be that you need to clear the theme cache 
(http://drupal.org/node/173880#theme-registry). 

Or maybe the function is not being processed.  You could simply rename 
the function (.._preprocess_...) and that may help.  Or, rename $vars 
with $variables.  Take a look at these two pages. 

http://drupal.org/node/223430
http://drupal.org/node/223440


Sorry I can't be more help with the exact naming to use.

- John

**************************************************
John Callahan
Geospatial Application Developer
Delaware Geological Survey, University of Delaware
227 Academy St, Newark DE 19716-7501
Tel: (302) 831-3584  
Email: john.callahan at udel.edu
http://www.dgs.udel.edu
**************************************************



Scott Matthews wrote:
> Is there nothing more that you did for this?  I just plugged this in 
> replacing the version of that method I had before and it did not work. 
>  It's still not recognizing my page-type.tpl.php.
>
> Did you mean to name the file template.tpl.php, or did you mean 
> template.php?
>
>
> On 4/10/09 9:55 AM, "Aldo Martinez Selleras" <aldo at caonao.cu> wrote:
>
>     this work for me, in template.tpl.php
>
>     function _phptemplate_variables($hook, $vars) {
>     if ($hook == 'page') {
>         if ($vars['node'] && arg(2) != 'edit') {
>             $vars['template_files'][] = 'page-'. $vars['node']->type;
>         }
>         return $vars;
>     }
>
>     them , i create some files!
>
>     page-blog.tpl.php
>     page-forum.tpl.php
>     page-privatemsg.tpl.php
>     page-my_node.tpl.php
>
>
>     --
>     ----------------------
>     Aldo Martinez Selleras
>     Especialista en Telematica
>     CITMATEL GND Camaguey
>     Tel: 53 32 291661
>     Linux User #364356
>     --
>     [ Drupal support list | http://lists.drupal.org/ ]
>
> ------------------------------------------------------------------------
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/support/attachments/20090410/c01de4f4/attachment.htm>


More information about the support mailing list