By reubenavery on
Long enough subject :-)
Yes, I am needing to override what is going on in page.tpl.php for a specific node content-type and I'm wondering the "drupal best practice" way of going about it.
My needs extend outside what happens within node.tpl.php, (regards the page title etc.. want to move it within the content area of this content type)
I don't really want to add hardcoded if-thens into my page template.. but page-node-[contenttype].tpl.php i guess is not supported. Or is there a different pattern for that?
Thanks,
Reuben
Comments
create a
create a page-contenttype.tpl.php file.
in the original page.tpl.php add this line to the top (changing the necessary bits)
~silverwing
_____________________________________________
MisguidedThoughts | showcaseCMS
Not exactly a "best
Not exactly a "best practice" approach. Add another template naming suggestion instead:
Now you'll have your "page-[contentType].tpl.php" to work with.
⎋ joon park
–www.dvessel.com–
Drupal 7
For Drupal 7, do this instead:
Put it in template.php in your theme folder. And clear cache.
I am using fusion so I used
I am using fusion so I used the templete.php of the core theme and put this lines.
then, in my sub theme I have create a page--book.tpl.php but it couldn't read it...
- Empty cache/
- Try to copy templete.php to the sub theme and chane all MYTHEME_...
Managing Partner at Reasonat
Works like a charm
Thanks!
I believe this only works if
I believe this only works if you name the template file - page--[content-type].tpl.php. So... you need two hyphens then the content type machine name.
I'm new to Drupal, but read
I'm new to Drupal, but read this on the Pro Drupal Development book. Not sure if this will help, may be some of u experts can clarify for me too.
yes
you can create any node-contenttype.tpl.php for any content type you create.
But the original poster wanted a specific page-contenttype to style the whole page differently. (node-contenttype.tpl.php will just alter the $content part - the title, text, add comment, terms, etc. page-whatever alters the look of the whole page.
In Drupal 6, I think you can create a page-contenttype.tpl.php in your theme and the theme engine picks it up.
In Drupal 5 you have to have a workaround for it.
~silverwing
_____________________________________________
MisguidedThoughts | showcaseCMS
bluemarine vs garland
In 5.7, garland automatically reads page-contenttype.tpl.php but bluemarine does not. In fact I was unable to force it to do so with the following code: (node type is type 'detail')
<?php
if ($node->type == 'detail' ) {
print $node->type;
include page-detail.tpl.php;
return; }
Still will not include the page-detail file - Any ideas?
It will not work for 5 or 6.
It will not work for 5 or 6. You have to add those suggestions yourself.
For Drupal 5, see the example I posted above.
For Drupal 6, you have to use preprocess functions to do the same.
More can be read in the handbook page for 6.
⎋ joon park
–www.dvessel.com–
Not working for a content type in 6
Hello,
I've added you example to the top of my page.tpl.php:
but the new page will not take. In this case I called the page page-client-page.tpl.php (taken from the client page content type I created).
Renaming the default page to page-node-76.tpl.php works but only on the one page and not the others made by the same content type.
Any suggestions?
Jon
Re: Not working for a content type in 6
I believe that this is supposed to go in the template.php in your theme directory... Which I did try and still nothing.
I believe we shouldn't even have to do that since this is supposed to be a basic feature of Drupal
Re: Not working for a content type in 6
I can't get it to work by adding a page template based on the content type in my themem directory.
i.e my content type is called x
My page template is named page-node-x.tpl.php
Drupal 6 doesn't pick it up......
same error
I'm trying to do the same thing in Drupal 6 - create a url specific theme. It is for a basic form page. However page-my-url.tpl.php is not being picked up in the theme directory.
You can override page.tpl.php with page-node.tpl.php
That works in 6, but doesn't help you override a specific node type.
_
Just add this to your template.php in Drupal 6 to enable content type-specific page.tpl.php:
Groovy
Groovy, I've tried a bunch of similar snippets but this last one is the only one that worked for me (and is the simplest of them all)...
White Screen of Death if function is already in template.php
If there already is a function called phptemplate_preprocess_page in your template.php you will get a WSOD, in which case you should just insert the code part in the already existing function.