Exclude content when using include

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
peroyomas
Forum Newbie
Posts: 2
Joined: Thu Oct 08, 2009 3:23 pm

Exclude content when using include

Post by peroyomas »

Is there a way to don't include a specific section of a page while using the include function?
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: Exclude content when using include

Post by JNettles »

If statements? Based on the limited information you posted that's the best help I can give.
peroyomas
Forum Newbie
Posts: 2
Joined: Thu Oct 08, 2009 3:23 pm

Re: Exclude content when using include

Post by peroyomas »

What I want to do is to have a page and when I include it in another page don't include a specific section, that would be viewable by default.

Original page

Code: Select all

 
Page content
<section>
Section content
</section>
 
Page when included

Code: Select all

 
Page content
 
pa28
Forum Newbie
Posts: 7
Joined: Mon Oct 05, 2009 9:26 pm

Re: Exclude content when using include

Post by pa28 »

Right... define a variable in your 'including' file - i.e. the one which is including the other:

Code: Select all

$isIncluded = true;
And then in your included file:

Code: Select all

 
Display this bit.
And this bit.
<?php if(!isset($isIncluded)) { ?>
But not this bit.
<?php } ?>
 
Post Reply