Hi,

I'm setting up a site with a forum, a shop and some simple service pages. I'm using Drupal 5.1 and PHPTemplate. I have created the following page templates:

page-forum.tpl.php - for theming forum pages
page-shop.tpl.php - for theming shop pages
page.tpl.php - for theming all other pages

However, this works only at the "entry level" of the forum but not in forum topics:

?q=forum (forum start page) - uses page-forum.tpl.php
?q=forum/1 (choosing a forum) - uses page-forum.tpl.php
?q=node/1 (opening a forum topic) - uses page.tpl.php but I want it to use page-forum.tpl.php !

I'm not sure as to how I can tell Drupal to use page-forum.tpl.php for all forum pages including topics. The same issue arises in the shop: all shop related pages should use page-shop.tpl.php, not just the first page in the shop.

Do I need to use Pathauto to solve this? If yes, how do I need to configure it? What if I want to use clean URLs?

Thanks for advice!

Comments

.carey’s picture

This may be what you are looking for (http://drupal.org/node/46027#comment-213839) by bumathan:

if (arg(0) =="forum" && is_numeric(arg(1))) {
    include 'page-subforum.tpl.php';
    return; }
if (arg(0)=="forum") {
    include 'page-form.tpl.php';
    return; }

:) Isn't that sweet? ;)

vm’s picture

This thread may help as well ... http://drupal.org/node/65171

futurist’s picture

Thanks for your inputs. I looked into them and here is what I found:

I can't use the solution using args, because in forum topics none of the args contains "forum". They just contain "node" and a numeric value. So they don't indicate we are in the forum. Apart from that, there is logic in tpl.php that I think should rather be in template.php (as of Drupal 5).

Overriding theme functions provides a perfect way to modify the forum list output (I'll try that later), but it doesn't allow me to switch the page template in forum nodes.

I did some more research and found this solution: Switch the page template based on the node type, which - in the case of forum topics - is "forum". I now have this in my template.php file:

function _phptemplate_variables($hook, $vars) {
  switch ($hook) {
    case 'page':
      if ($vars['node']->type == 'forum') {
        $vars['template_files'] = array('page', 'page-forum'); // most important last
      }
      break;
  }

  return $vars;
}

Now all forum nodes use the page-forum.tpl.php template file. Anything wrong with this approach? ;)

Here is where I found information concerning this method:

http://group42.ca/take_control_of_your_phptemplate_variables
http://www.lullabot.com/articles/hacking_phptemplate
http://www.nicklewis.org/node/825

amandawolfe’s picture

Having the same exact quandary. I'm trying to get this to work for D6--any ideas? I already have the page-forum.tpl.php working fine for form and forum list, just not the actual forum post nodes.