Jump to content

Recommended Posts

i got a php website based on templates, and i want to make some changes.

it's based in header.tpl; mainpage.tpl; and footer.tpl

what i want to achieve is to have 2 header.tpl pages displayed separately. or at least 2 different headers.

on index.page i want to display header1.tpl and on any other page i want to display header2.tpl

 

how can i do that? please help!

Here's the code that triggers the template:

 

$template_output .= $template->process('header.tpl.php');

 

what i want to do is to process the header.tpl.php only if the current page is index.php

on any other page i want to process the header2.tpl.php

 

so visitors when enter the www.site.com or www.site.com/index.php will see one version of the header, and if the navigate away from index.php page they will see another header on the page

 

basically the difference between the 2 header.tpl.php files is one jquery banner....

Without know the rest of the code surrounding the template output, it would be difficult to give a clear solution, however, maybe this will give you some ideas:

 

function header( $name = null ) {
       if( isset($name) )
      	 $template_output .= $template->process('header-{$name}.php');
  	 $template_output .= $template->process('header.php');
}

i need something simple, exactly like this:

 

if the current page is www.site.com/index.php process header.tpl.php

if the current page is not www.site.com/index.php process header2.tpl.php

 

please help

Edited by work_it_work

That kind of depends on your code. You should be able to do something like:

 

$templateFile = ($_SERVER['PHP_SELF'] == '/index.php') ? 'header.tpl.php' : 'header2.tpl.php';
$template_output .= $template->process($templateFile);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.