This forum is for assistance with theme development.

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?

phpTemplate: '$title' conditional placement in node.tpl vs. page.tpl ?

I'm working on a site that has some interesting challenges in layout that would be made much much easier if I could get the title on the front page and the title on node pages to get called up in the same way.

With page.tpl.php the title variable is called thus:

				<?php if ($title != ""): ?>
					<h2 class="content-title"><?php print $title ?></h2>
				<?php endif; ?>

Some way further down, the $content is called.

In node.tpl.php the title variable is called thus:

 <?php if ($page == 0): ?>
    <h2><a href="/<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
  <?php endif; ?>

I am assuming there must be good reasons for this, but I'm too new at the code structure (or I'm just too dense) to figure it out.

My question is this: Is there an essential reason why the title variable is called by node vs. page using mutually exclusive conditionals? Would there be potentially dire (and/or unforseen) consequences to simply call ALL $title calls via node.tpl.php (without the conditional), and take out the $title call in page.tpl.php altogether?

I suppose I will just give it a shot in the morning, but what I'm afraid of is that it will seem to work, only to surprise me later.

Any thoughtful reply would be greatly appreciated!

Pages

Subscribe with RSS Subscribe to RSS - Theme development