By jdln on
How can I change the output of my page.tpl.php for different content types, but within a single page.tpl.php file?
So so for a blog, rather than create a new file called page-blog.tpl.php, can I write add some php to my page.tpl.php which will show some html for a certain content type?
Something like this;
<?php if ($node-blog): ?>
<h1> This is a page for the blog content type</h1>
<?php else: ?>
<h1> This is a page for all content types except for blog</h1>
<?php endif; ?>
Thanks
Comments
_
Use
if ($node->type == 'blog'):Thanks WorldFallz Ive
Thanks WorldFallz
Ive expanded it to this, seems to be working fine.
How can I do the same thing
How can I do the same thing for taxonomy pages?
Ive tried searching for this but i dont know what words to search for. Is there a name / resource for this stuff I should look at?
Thanks
_
you mean format pages different for taxonomy terms? Yep. You'll want to get familiar with the Overriding themable output section of the handbook. Specifically the Core templates and suggestions and Working with template suggestions pages. Instead of putting all this logic in a single page.tpl.php file, you can setup different template files for different conditions.
For some ideas specific to taxonomy pages see http://mustardseedmedia.com/podcast/episode31.
Hi WorldFallz I know about
Hi WorldFallz
I know about theming with a tpl.php file but im trying to do it in my page.tpl.php.
Is there a version of the code below that would recognize a taxonomy page, rather than the node type?
if ($node->type == 'blog'):Thanks
_
if (arg(0) == 'taxonomy'):Thanks a lot. Is there a
Thanks a lot.
Is there a good resource where I can find this sort of code or is it just one of those things you have to know?
_
There's a snippets section in the handbook that has lots of good stuff but there will always be times when you need to improvise. I found that getting familiar with those snippets did help me to figure out things that weren't there though.
Ill do some reading. Thanks
Ill do some reading. Thanks