Hi Michelle,
I have a custom page-forum.tpl.php file that works great for the forum lists but obviously doesn't affect the forum posts themselves because they're nodes. Lots of people have this question and I've found some solutions, but I can't seem to make them work. I'm not sure if it's an advanced forum thing, a drupal 6 thing, or (more likely) an "I dont know what I'm doing" thing.
Here's the technique I'm trying to use: http://drupal.org/node/154513
And here's the snippet:
<?php
/**
* This snippet loads a custom page-forum.tpl.php layout file when
* users click through to the login, request password or register pages
*/
function _phptemplate_variables($hook, $variables = array()) {
switch ($hook) {
case 'page':
// node type isn't available in template.php so we have to go get it.
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
$type = $node->type;
}
if (($node->type) == 'forum') {
// if the node type is forum load the page-forum.tpl.php layout
$variables['template_file'] = 'page-forum';
}
break;
}
return $variables;
}
?>
Do you know if there's something I'm not doing to make it work with advanced forum? Thanks so much for your help!
Comments
Comment #1
michelle_phptemplate_variables is a 5.x function. You need to look into the new preprocessers. Advanced forum doesn't do anythign with the page preprocess at this point so there should be no conflict.
Michelle
Comment #2
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #3
amandawolfe commentedHi Michelle,
So I got it to work in a different way, by putting this in my page.tpl.php:
It works great for everything except when you go to actually post a forum reply, the different page template doesn't apply. Which makes total sense because it's a comment, not a node. I've been searching and I haven't seen anyone with a solution for this thus far. Any ideas? Thanks so much!
Comment #4
q8doc commentedi think you can have a look at the old flat forum... how it created the node-forum.tpl
i think its the best solution, else i think, as usual, i misunderstood.
???may be ???
Bisher
Comment #5
michelleFlatforum didn't theme the forum pages, either.
I don't know of any way to tell a reply to a forum post apart from any other reply on the edit page, but I haven't dug into it. Your best bet is to put in some debugging code and see what variables are available and see if there's anything you can use.
Michelle
Comment #6
heacu commentedsubscribe
Comment #7
stewit commentedThank you! I spent a while trying to get a solution, was on the right track, however was using an if statement to change the div I wanted, but I think this way is much tidier :)
Cheers,
Stewart
-- EDIT --
I found that this caused a few errors (such as
Notice: Undefined variable: node in include())when coming from /user pages, as they're not considered nodes. So use the following instead is my suggestion: