Hi,
I've been working on a new site (4.7 using phpTemplate) which has a fairly standard layout with a Blog/Articles section and a forum. But I've been wanting the forum to have a different layout, the FlatForum module got me halfway there, but I need the forum page template to be different too.
So I made a little script in the page.tpl.php file to detect if the user was on the a forum page and deliver a different template if they were. Here is the code I'm using, it basically uses the url to detect if it is a forum page or if the node type is 'forum':
<?php
//////////////////////
// DETECT FORUM PAGE //
//////////////////////
$ukf_url_expode = explode('/', url($_GET['q'], NULL, NULL, NULL));
$ukf_url_expode_rev = array_reverse($ukf_url_expode);
$ukf_url_nid = $ukf_url_expode_rev[0];
$sql = "SELECT vocabulary_node_types.vid
FROM node, vocabulary_node_types
WHERE $ukf_url_nid = node.nid
AND node.type = vocabulary_node_types.type";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
if ($ukf_url_expode[0] == 'forum' or $row[0] == '1' ):
//////////////////////
// START FORUM PAGE //
//////////////////////
?>
**Forum Template Code**
<?php
///////////////////////
// START NORMAL PAGE //
///////////////////////
**Normal Template code**
<?php
endif;
?>
else:
?>
So far it is working fine, but I'm a designer really, not a programmer (I just learn what I need to as I go along) so I'd like the opinion of someone more versed in PHP as to whether it is a good idea to use this system on a production site or if it is a horrible hack that'll cause me problems later.