How to exclude file from particular pages?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
samuel13
Forum Newbie
Posts: 2
Joined: Wed Jan 05, 2011 9:33 am

How to exclude file from particular pages?

Post by samuel13 »

Hello all,

I am new here so please forgive the coding language.

I am working on a clients site that someone else created in php. I need to exclude a file that is included in my index.php from all pages except the index page itself.

In my index.php it includes the header.php for the site. The header.php file includes a Topnav.php file. The TopNave.php file is what I need to exclude from all pages except the index (home) page.

Could someone help me understand how this can be done?

Here is the code in my Topnav.php file -

Code: Select all

<div id="greenStripe"> <img src="/_images/bannerGreen.jpg" width="895" height="26"/> </div>
<div id="flash">
    <?php
    include "flashObject.php";
	?></div>
<div id="topNavContainer" style="width:895px">
<?php
	include "topNav.php";
?>
</div>
jankidudel
Forum Commoner
Posts: 91
Joined: Sat Oct 16, 2010 4:30 pm
Location: Lithuania, Vilnius

Re: How to exclude file from particular pages?

Post by jankidudel »

In the header.php file just remove line where it includes your not wanted file, in index.php include it manually
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: How to exclude file from particular pages?

Post by social_experiment »

You could simply remove include 'topNav.php' from all the pages except index.php. Removing the page (topNav.php) will result in errors from the include() function.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
samuel13
Forum Newbie
Posts: 2
Joined: Wed Jan 05, 2011 9:33 am

Re: How to exclude file from particular pages?

Post by samuel13 »

jankidudel wrote:In the header.php file just remove line where it includes your not wanted file, in index.php include it manually
This worked perfectly! I thought that if it is included in the index.php, that it would be on all my pages...? Guess not.
Post Reply