I've created a custom theme for a client's site, and this includes a blog template named page-blog.tpl.php. This looks fine when I access it at
http://www.hopechurch-madison.com/blog

but not
http://www.hopechurch-madison.com/blog/

or
http://www.hopechurch-madison.com/blog/2

I figurne it must be some stylesheet problem, but it looks like they're both including themes/hopechurch/blog.css . I'm looking at the diff of the output, and i see a few differences such as

Submitted by andy on Wed, 01/02/2008 - 23:40.

showing up only on the version without the trailing slash. But I'm baffled as to why the styles don't make it for everything else, and I don't see anything different that would explain why the styles aren't taking for those other pages.

TIA.

Comments

romand’s picture

Try to use node-blog.tpl.php

miche’s picture

I believe that node-blog.tpl.php themes the individual node, not the parent page that displays them as teasers.

---------------------------------------------------
Michelle Lauer
michellelauer.com

PhilipReed’s picture

I appreciate the suggestions. However, copying my page-blog to node-blog didn't really fix anything; in fact, it actually broke the version without the trailing slash!

So I've got to do some troubleshooting and see if I can better understand how these fit together.

http://philipreedtech.com

Manamarak’s picture

I am trying to customize the page in which the blog node is displayed as well, and have run into the same difficulty.

I can edit the way the page, rather than the node is displayed by editing page-blog.tpl.php, but when users access the blog via the recently posted blogs block, the page seems to load using page.tpl.php.

Is there a work-around for this? Perhaps I could edit the recently posted blogs block to redirect to the teaser view? Any ideas?

You can see where I am stuck here:

http://www.illustratedphotography.com

If you access the page from the menu on the left (via edblog) it displays the way I want it to, with a customized moto and slogan, but if I access it from the block on the right it takes you to the the node rather than the teaser and it is displayed without my header and custom slogan and moto.

Help will be appreciated.

dvessel’s picture

You can add this bit of debugging code within template.php inside your theme.

function _phptemplate_page($vars, $suggetions = array()) {

  print '<pre>'. check_plain(print_r($suggestions, 1)) .'</pre>';
  return _phptemplate_default($vars, $suggestions);
}

That will print out all the possible template names for "page", i.e. page-blog, page-forum, etc.. It will exclude the extension.

Philip, every example you listed should work. The only possible problem are path alias. If those paths were created with manual path aliases or pathauto, it will not work. The internal paths determine how the templates are named.

You can see how they are constructed with this: http://api.drupal.org/api/function/phptemplate_page/5 (scroll to the bottom)

PhilipReed’s picture

Thanks, dvessel.

Adding that debugging leads to the predicted results, if I'm understanding what I'm looking for.

http://www.hopechurch-madison.com/blog and http://www.hopechurch-madison.com/blog/ both generate:

Array
(
[0] => page
[1] => page-blog
)

http://www.hopechurch-madison.com/blog/2 generates:

Array
(
[0] => page
[1] => page-blog
[2] => page-blog-2
)

So all of this is as I'd expect and doesn't really help me home in on the difference between the "trailing slash" and "no trailing slash" versions. It does give me one more troubleshooting tool to play with though.

Thanks again!

http://philipreedtech.com

rbilei’s picture

Hi Philip,

I'm just beginning to understand things in Drupal so I'm probably at least as confused as you are :)

I had the same problem while attempting to customize a Drupal blog (I want it to be integrated in the site), so I found your post while searching for an answer. I also found another post by a person who seems to not be able to get around this either.

What I eventually did is no elegant solution and I'm not proud of it and it doesn't mean I understand things better, maybe because I'm not a programmer, I can barely scratch the surface on PHP code. But it works, so here's what I did. Inspired by this, I included the following code at the beginning of my page.tpl.php file:

<?php if ($node->type == 'blog'): 

    include 'page-blog.tpl.php'; /*load  page-blog.tpl.php */
    return;

	else: ?>

and this at its very end:

<?php endif; ?>

Good luck, hope you'll find this useful.

Radu -
Timişoara, România

PhilipReed’s picture

Radu,

Thanks for the suggestion!

Here's what happens when I do that. First of all, I have to rename page-blog.tpl.php to something like _page-blog.tpl.php, or else the page-blog one overrides the page one anyway in case of blogs.

So after I do that, it doesn't appear that the type is being correctly set in the code or something. I echoed out the contents of $node->type, but it's empty when I'm on the blog.

I think I'm going to have to dig around in the source and figure out where the actual pieces of the CSS that are missing are generated. Uggh! I'll report back on what I find.

Thanks, all.

- Philip

http://philipreedtech.com

PhilipReed’s picture

I fixed my problem. Scroll to the end if you don't want the whole troubleshooting chronology.

I noticed that according to Firebug, this CSS:

#left_column {
float:left;
max-width:108px;
padding-left:20px;
padding-top:5px;
}

should be coming from themes/hopechurch/blog.css, line 7. But it's not in the case with the trailing slash, and that makes me want to try pathing it out explicitly. It should be leading to http://www.hopechurch-madison.com/themes/hopechurch/blog.css, but apparently isn't.

So I pathed it out explicitly in the blog. And now it works.

Thanks to all.

- Philip
http://philipreedtech.com

digitalfreak’s picture

I ran into the same problem a few days ago, after reading in the handbooks. I know drupal will look for page-blog.tpl.php before it look for page.tpl.php, it seems to me it is a priority thing in a if-clause. I haven't check the source, but I imagine it will look for sth like page-node-blog.tpl.php as well, then i gave it a try and BINGO !! that is the file it will look for when you go to URL yousite.com/blog/* , * is the wildcard.

edited: seems I forgot I have put some codes inside the template.php in order to achieve what i said, you can read on from here http://drupal.org/node/45944#comment-263744

btw, i went to your site's "about" page and love the photos that will change itself, and I did a check, it's not flash, i wonder how you did that ? Is there a module to do that in drupal ?

netentropy’s picture

this page-node-blog.tpl.php did not work for me. is there something that is needed in the template file

rastanot’s picture

Open up template.php and add this if statement.

     if (in_array('page-node', $vars['template_files']) && $vars['node']->type == 'blog')
    {
        $vars['template_files'] = array('page-node-blog');
    }

Now for every content type that is 'blog' it will use your new page-node-blog.tpl.php file.

dataphile’s picture

use

http://www.hopechurch-madison.com/blog?q=blog/2

instead of

http://www.hopechurch-madison.com/blog/2

in the menu item that you want to point to blog/2 use

blog?q=blog/2