This forum is for assistance with theme development.

New PHPTemplate functionality

I have been readying the next version of PHPTemplate for the 4.6 release (the RC should be out very soon now). You can get this in CVS now, but it is NOT meant for 4.5. I am still undecided wether to back port it.

  1. Did away with the template caching. I did some benchmarking and it appears that file_exists() is nowhere near as heavy an overhead as I thought. This means you don't have to go to admin/themes to have the cache refresh.
  2. $seqid and $zebra variables are now available to all templates without needing to do the template.php hack (see: http://drupal.org/node/16383).
  3. $node object available in page.tpl.php on node view pages. This allows for some very creative layouts, and styling the entire page different for different node types (by adding a node-$node->type class to the body for instance).
  4. Automatic loading of node-$type.tpl.php files. You can create different templates for story / blog / etc. nodes. Practically, I still think CSS would be better for this, but it has been requested often, so here it is.
  5. Automatically uses a favicon.ico if found in the theme directory.

How do you create two page.tpl.php for a theme?

In Protecting content from non-logged in users when using phptemplate overrides there is talk about how to customize the template.php so that anonymous users cannot see private information on the site, since overiding via phptemplate goes around permissions.

I'd like to extend this to allow more customization in two ways

  1. display different page layouts for anonymous and logged in users (eg- display left and right columns only for logged in users).
  2. create different page layouts depending on what is on the page (eg- blog)

To approach task #1 i've tried this in my template.php:

/**
* check if the user is logged in before invoking the template override
*/
global $user;
if($user->uid) { // check to see if the user is logged in
	function phptemplate_page($content, $title = NULL, $breadcrumb = NULL) {
  	return _phptemplate_callback('page', $vars);
	}
}

elseif (!  $user->uid) {
	function phptemplate_page($content, $title = NULL, $breadcrumb = NULL) {
 	 return _phptemplate_callback('page_anon', $vars);
	}
}

This, in theory, would call page_anon.tpl.php for anonymous users and page.tpl.php for registered users. But I get this error:

Fatal error: Cannot redeclare phptemplate_page() (previously declared in *edit*/themes/engines/phptemplate/phptemplate.engine:143) in *edit*/themes/my_theme/template.php on line 15

The line # is actually corresponding to the first mention of phptemplate_page, i've edited out the parts that you can see by following the link above.

So am I to assume that it's not possible to customize the call to page.tpl.php? Or am I missing something else?

I think the problem will also help solve task #2.

template.php is giving me problems

I apologize for the double post. I shoudl have posted this problem in this forum, but it appears to be too late.

I am having a problem with template.php and theming modules. PLease read about my problem here:

http://drupal.org/node/18276

Can anyone help?

Thanks in advance!

Mateo

Xtemplate and Taxonomy Images

How would you go about adapting xtemplate.engine to display a Taxonomy Image? I changed the title section of the header as follows:

if ($title = drupal_get_title()) {
$xtemplate->template->assign("title", $title);
$xtemplate->template->assign("breadcrumb", theme("breadcrumb", drupal_get_breadcrumb()));
$xtemplate->template->assign("taximg",taxonomy_image_display($term->tid));
$xtemplate->template->parse("header.title");
}

What did I do wrong?

Display Post Information with Manji

The global checkboxes that are intended to control the display of Post Information (i.e.: Username, Timestamp, etc.) do not seem to function with phptemplate themes such as Manji or Obsidian, though they do with Xtemplate-based themes. Has anyone else experienced this problem and found a solution?

Smil + VML implementation ... dtd question

Hello Friends,

I have had some success implementing the time2 and vml behaviors into this portal. Time2 worked with the strict dtd, but not the vml, so we changed to the transitional dtd. We are able to use the time2 behavior via the css as class="time" under the namespace "ed" (rather than t:)...

As things are working as expected, my question is then, are there un-seen consequences to using the transitional dtd that we aren't aware of?

Pages

Subscribe with RSS Subscribe to RSS - Theme development