By Boogle on
Does anyone know how this is done?
I want the page-blog.tpl.php file to change all the pages for each node within that content type and not just first page (www.example.com/blog). The first page is a view I’ve created and editing the page-blog.tpl file does change the layout – however it does not change each page for each node.
I’ve tried entering various sections of code into my template.php file to bypass the page.tpl.php file but I’ve had no success. The most recent code was this:
<?php
function framework_preprocess_page(& $vars) {
if (isset ($vars['node']) && $vars['node']->type == "blog") {
$vars['template_files'] = array();
$vars['template_files'][] = 'page-blog';
}
?>
It didn’t work, so I’m stuck. Any ideas?
Thanks
Comments
..
I have a similiar issue that I have been trying to resolved. I created a page-story template to use for displaying stories rather that the default page template. I have tried multiple function calls in my template.php and nothing has worked...it keeps using the default template every time.
My ongoing issue is here: http://drupal.org/node/894176
I keep thinking I am missing something really basic to make this happen but it has had me stumped for a few days.
Why don't you try changing
Why don't you try changing the node.tpl.php instead.
Try creating a node-blog.tpl.php file.
Not sure about the theming
Not sure about the theming solution to this, but you could try the Panels module - its perfect for making different page templates per content type. Just enable the node template, and then add varients with selection rules: node type:yourcontenttype...
Makes it really easy to theme all your content types.
It can be a little slow with performance when using the flexible layout, but the standard layouts are great, and you can always hard code your flexible layouts when done.
Also the Panels everywhere module adds an interesting extra to this set up - you can completely do away with the page.tpl and blocks and theme you're whole site as panels by having one main site template panel.
I've noticed this to be really fast - faster even than garland theme or basic/framework etc with much less cross browser problems...
Joe
Not a fan of panels
I don’t like the code used with the panels module. I only use it for creating the odd page, like the front.
I already have a node-blog.tpl.php, that doesn’t let me change the page layout, it only lets you control the fields/content. I want to get into the main wrapper div but unfortunately that’s in the page.tpl.
Try this
This not only creates template suggestions based on content type (which, as you note, doesn't help for blog entries), it also creates them based on the URL alias (so page-blogs.tpl.php could work for the blog entry pages if you use the pathauto module and set the default path for blog entries to
blogs/[author-name-raw]/[title-raw]). It also solves the problem with the front page that someone mentioned.Doesn’t work for me!?
Doesn’t work for me. I did exactly what you said. I’d already tried setting the URL aliases with Pathauto. Tried it with several different variants of your code but no luck I’m afraid. I’m curious to know if anyone has successfully done this because I can’t find anything on the internet solving this problem.
Thanks anyway.
Well, yes
Yes, someone has successfully done it. I've done it, using the instructions I just offered. Lots of other people have done it, too. You're doing something wrong, but without more information, it's hard to say what.
You’re right...
My apologies zbricoleur, I was indeed doing something wrong. It works perfectly. Thanks for your assistance.
Glad to hear it's worked out.
Glad to hear it's worked out. For the benefit of others who may read this in the future, could you tell us what the problem was?
Thanks a lot!
Just used your function on my custom theme and it works great!
Works great!
Thanks, saved me hours of searching and building my own solution.
for me it is working
For me it is working for the blog content types
because we are customized blog templates with a custom module and different template files used for each blogger
.So in blog detail page (ie.node) it automatically fall backs to a view with a path node/%.Then i used above template sysetm for load my page template from alias.So i will remain on blog page when we show detail of each blog and viceversa
thanks for your snippet
Anyone know what the Drupal 7 code would look like for this?
Anyone know what the Drupal 7 code would look like for this?
Anthony Pero
Project Lead
Virtuosic Media
http://www.virtuosic.me/