page-blog.tpl.php for all blog entries, not just /blog?

Rob_Feature - March 17, 2007 - 19:20

Hey all...
On my site, I have no sidebars, its just one column. However, only on the blog part of the site, I want a sidebar. So, it makes sense that I created a page-blog.tpl.php file and added my sidebar in that.

Ok, that works great...sorta.

It displays exactly what I want on the /blog page. However, if you go directly to a blog post node, the sidebar isn't there (the page-blog.tpl.php file doesn't apply).

Is there a way to get this page-blog.tpl.php to apply to all my posts? (ideally, I would put the sidebar in the node-blog.tpl.php file, but you can't print a sidebar in there)

See the page with the sidebar at: http://www.mustardseedmedia.com/blog
See it not working on an individual post at: http://mustardseedmedia.com/blog/2007/mar/17/web_standards_are_good_for_...

Any help would be appreciated.

Thanks!

Have you tried this?

Xano - March 17, 2007 - 19:50

Have you tried this?

Exactly

Rob_Feature - March 17, 2007 - 20:21

Yes, Xano...this is exactly what I'm talking about.

I created a blog specific tpl.php file...however, it's not displaying that page for all my blog entries (when you view the full node). Looking for some help on why that is happening...

Simple fix?

jvalletto - March 17, 2007 - 21:47

I think the problem you are having is a downfall found in Drupal with the templating system, and how it calls path based template files (ex. page-blog.tpl.php[ /blog/blah/blah/ ]).

The problem is the with the way drupal uses it's path system and clears the $_GET['q'] variable it needs to get the path based template files in PHPTemplate.

I have a patch you can use, assuming you are using APACHE, as I am unsure if it works on another system.

Add this line to the top of your template.php file. [Without the <? php ?> tags.]

<?php
$_GET
['q'] = str_replace('q=', '', $_SERVER['QUERY_STRING']);
?>

Let me know if this helps.

Jeremy

Possible Solution

jared12 - January 15, 2009 - 22:12

Another solution to the issue of a page-custom.tpl.php template not being applied to the the individual node pages can be found here. I just added the code from comment 1135771 to the template.php file in a Drupal 6.x installation, and it appears to do the trick.

 
 

Drupal is a registered trademark of Dries Buytaert.