home resources search newsjoinmembers: 6958
PHP Flash Java Ruby Windows Linux
Hiveminds | Sat, 2006-06-17 09:53  tags: ,

Here's how to get a different page template per url is important . This comes in use when you do not want to have the sidebars and other page eliments appear in admin sections or forums.


<?php

function _phptemplate_variables($hook$vars = array()) {
  switch (
$hook) {
    case 
'page':
      if (
$vars['is_front']) {
        
$vars['template_file'] = 'page-index';
      }
      else {
        
$uri_request_id $_SERVER['REQUEST_URI'];
        
$section explode("/"$uri_request_id);
        switch (
$section[1]) {
          case 
'admin'$vars['template_file'] = 'page-admin'; break;
          case 
'group'$vars['template_file'] = 'page-group'; break;
          case 
'question'$vars['template_file'] = 'page-vocab'; break;
          case 
'add'$vars['template_file'] = 'page-addnode'; break;
          default: 
$vars['template_file'] = 'page-default';
        }
      }
    break;
  }
  return 
$vars;
}
?>

or in your page.tpl.php you can use

<?php

if ($is_front) {
    include 
'page-index.tpl.php';
    return;
}
$uri_request_id $_SERVER['REQUEST_URI'];
$section explode("/"$uri_request_id);
switch (
$section[1]) {
    case 
'admin': include 'page-admin.tpl.php'; break;
    case 
'group': include 'page-group.tpl.php'; break;
    case 
'question': include 'page-vocab.tpl.php'; break;
    case 
'add': include 'page-addnode.tpl.php'; break;
    default: include 
'page-default.tpl.php';
}

?>

printer-friendly version

Hiveminds's picture
This article brought to you by the Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously
Thoughtbox - So what did you think?



 
 
Web Developers Silverlight PHP Adobe Flex Silverlight Adobe Flex Drupal Adobe Flex Silverlight
 videos
 articles
 blogs
 comments
 downloads
sitemap

Newsletter

Get updates on Hiveminds services, articles and downloads by signing up for the newsletter.

Editor's choice

Some of the better articles, stories and tutorials found at Hiveminds.

Find more

Find more of Hiveminds articles, stories, tutorials and user comments by searching.




Picked links

Hand picked websites and articles from around the web that provide quality reading.

page top