This forum is for assistance with theme development.

Example: Multiple Template Site

For those interested, I've been playing around with multiple templates, and I have a site up and running that uses this simple hack. http://news.plu.edu

I made some changes to the xtemplate theme file to allow for multiple templates. Check out code below.

Put this at the top of the file.

// Get current template
$current_template = variable_get('mxtemplate_template', 'default');
// Get current directory
$current_dir = $_GET["q"];
// Set template directory (look for path match)
$template_directory = mxtemplate_match_paths ($current_dir, $current_template);

Add something like this function to the .theme file

function mxtemplate_match_paths ($curpath, $curtemp){
  /*
  ** Take current path, match against stored paths 
  ** If a match exists, update theme template
  ** If no match, assign $curtemp as default theme
  ** Return theme template
  */

  // Pages that should use different templates
  $page_home = "49"; // Home is nid #49
  $page_campus_news = "5";  // Campus News is nid #5
  $page_notices = "54"; // Notices is nid #54
  $page_events = "130";  // Events is nid #130
  $page_plunews = "31";  // PLU News is nid #31
  $page_news = "50";  // News is nid #50
  $page_archive = "51";  // Archive is nid #51
  $page_classifieds = "13"; // Classifieds is nid #13
  $page_newsstaff = "320"; // News Staff is nid #320
  $page_photoservices = "321"; // Photo Services is nid #321
  $page_facultyindex = "318"; // Faculty Experts index is nid #318
  $page_facultylist = "319"; // Faculty Experts list is nid #319
  $page_speakersindex = "314"; // Speakers Bureau index is nid #314
  $page_speakerslist = "317"; // Speakers Bureau index is nid #317
  
  // Adjust the argument incase the page is being viewed through the admin
  $check = arg(0, $curpath);
  
  // Set argument
  $argument = arg(2, $curpath);
  
  // Assign alternate templates
  if($check == "admin"){
    $path_template = "admin";
  }
  elseif($argument == $page_home){
	$path_template = "home";
  }
  elseif($argument == $page_campus_news){
	$path_template = "campus-news";
  }
  elseif($argument == $page_notices){
	$path_template = "notices";
  }
  elseif($argument == $page_events){
    $path_template = "events";
  }
  elseif($argument == $page_plunews){
	$path_template = "plu-news";
  }
  elseif($argument == $page_news){
	$path_template = "news";
  }
  elseif($argument == $page_archive){
	$path_template = "archive";
  }
  elseif($argument == $page_classifieds){
	$path_template = "classifieds";
  }
  elseif($argument == $page_newsstaff){
	$path_template = "news-staff";
  }
  elseif($argument == $page_photoservices){
	$path_template = "photo-services";
  }
  elseif($argument == $page_facultyindex){
	$path_template = "faculty-experts";
  }
  elseif($argument == $page_facultylist){
	$path_template = "faculty-experts";
  }
  elseif($argument == $page_speakersindex){
	$path_template = "speakers-bureau";
  }
  elseif($argument == $page_speakerslist){
	$path_template = "speakers-bureau";
  }
  else{
	$path_template = $curtemp;
  }
  
  return $path_template;

}

Within the xtemplate_page function add this below "global $mxtemplate;" but before " $mxtemplate->template->assign(array("

  
  // Get current template
  $current_template = variable_get('mxtemplate_template', 'default');
  // Get current directory
  $current_dir = $_GET["q"];
  // Set template directory (look for path match)
  $template_directory = mxtemplate_match_paths ($current_dir, $current_template);

If you want to play around with this be sure to backup your xtemplate.theme file. This code is just an example. To make it work on your site you'll have to change it a bit.

Is this theme available for Drupal 4.5 (latest cvs)

Hi Cel..

I would really like to use the theme "bluesolid" (http://cyberdash.com/node/view/310) for my Drupal 4.5 (latest cvs) site, how easy is it to convert the theme to work on 4.5 (cvs)?? Any directions, or is it already done? Thanks for some great themes. Thumbs up for you mate!

Cheers
rjpa

Xtemplate block region: more than 2 regions?

Hi,

is anyone had modified the blocks module to support an additional region? For Xtemplate and drupal 4.4.

Someone succed to update this patch?
http://cvs.drupal.org/viewcvs/contributions/sandbox/killes/blocks/

Random quote from Quotes module in header?

Question:

Is it possible to have random quotes, pulled from the Quotes.module appear in my site header?

What code would I need in my xtemplate template for this? Would I also need code added to xtemplate.theme?

E

Phptemplate vars and methods

I am slightly confused by phptemplate. How am I supposed to know which variables or mathods are available? Is there some reference available?

Also, I wonder if $sidebar_left is atomic - i.e. I cant change the way in which the contents of the sidebars are arranged. A reference would come quite handy here.

I hope the answer to my question is not RTFS ;)

best regards.

phptemplate and internet explorer

For the people using phptemplate i thought i would ask becasue its driving me bonkers.

Pages

Subscribe with RSS Subscribe to RSS - Theme development