...

View Full Version : How can I make an included template to appear only on two pages



mexabet
10-16-2009, 12:19 PM
I need help to make an included template to appear only on two pages and not on other web pages of a CMS. Can someone point me in the right direction, please on how to use the "elseif" statement to accomplish this?

Right now tpl file appears on every page, which is not what I want.

<?php
//Display slide
include('myfirst.tpl');
?>

A hint of what I want to achieve is below:

<php
if "index.php"
include('myfirst.tpl')
elseif "list-image.php"
include('myfirst.tpl')
else
do nothing
?>

met
10-16-2009, 12:33 PM
first you need to determine the page.

If you are using $_GET as a method of navigating (i.e. showing content based on the URL) then it would be easy enough to achieve.

otherwise just put the include code on the pages you want, and don't put it on every other page.

mexabet
10-16-2009, 12:55 PM
Hi met,

I want to put the "include" code only on index.php. If you know the correct elseif code for it, please help me.


first you need to determine the page.

If you are using $_GET as a method of navigating (i.e. showing content based on the URL) then it would be easy enough to achieve.

otherwise just put the include code on the pages you want, and don't put it on every other page.

mexabet
10-16-2009, 01:55 PM
Sorry, I examine more closely and saw that the script uses $_GET['page'] method.

The pages are "list-album", "list-image" and "image-detail". I want the template to be show up on "list-album" and "list-image", but not on "image-detail". Any help will be appreciated.

met
10-16-2009, 02:51 PM
$page = $_GET['page'];
/* validate this */

/* put this where you want myfirst.tpl to appear */
if(!isset($page)) {
/* this condition means no page is requested
which implies you are on index.php */
} else if($page == 'list-album' || $page == 'list-image') {
include('myfirst.tpl');
} else {
/* this condition implies $page is set, but isn't list-album or list-image */
}

mexabet
10-16-2009, 03:12 PM
Hi met,

Thanks for your help. However, I got error these messages after inserting your code:

Warning: Unterminated comment starting line 76 in /home3/myaccountname/public_html/myste/index.php on line 76

Parse error: syntax error, unexpected $end in /home3/myaccountname/public_html/mysite/index.php on line 76





$page = $_GET['page'];
/* validate this */

/* put this where you want myfirst.tpl to appear */
if(!isset($page)) {
/* this condition means no page is requested
which implies you are on index.php */
} else if($page == 'list-album' || $page == 'list-image') {
include('myfirst.tpl');
} else {
/* this condition implies $page is set, but isn't list-album or list-image
}

abduraooft
10-16-2009, 03:34 PM
I need help to make an included template to appear only on two pages and not on other web pages of a CMS. Can someone point me in the right direction, please on how to use the "elseif" statement to accomplish this? How do you distinguish them? Or which are those two pages?

met
10-16-2009, 03:37 PM
Hi met,

Thanks for your help. However, I got error these messages after inserting your code:

Warning: Unterminated comment starting line 76 in /home3/myaccountname/public_html/myste/index.php on line 76

Parse error: syntax error, unexpected $end in /home3/myaccountname/public_html/mysite/index.php on line 76


missed the */ closing comment

mexabet
10-16-2009, 03:45 PM
abduraooft,

The pages I want the template to show are "list-album" and "list-image", but not on "image-detail". However, the matter has been taken care of.

met,

Thanks for your efforts. The matter is solved.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum