Jump to content

Is it possible for a page to know if it's been included?


aka_bigred

Recommended Posts

Is there any sort of built-in mechanism to determine if a certain page (call it the Includee) has been included within another page (call it the Caller)?

 

I want to have the Includee do something different if it's being included from some other caller page than if it's run on it's own.  It will output some page display headers/footers, etc if it's called directly by the user, but if it's been included by another page, just show it's "meat" w/out the header/footers.

 

I'm imagining some environmental variable, maybe an array, that holds each page that's been included.  If the Includee finds itself in that array, don't show the headers.  I think I could code something like this, but if there's some sort of system maintained list to use instead, that would be better than reinventing the wheel.

 

TIA

-S

Link to comment
Share on other sites

If you take a look at the page for the function on the php site:

http://uk3.php.net/include/

 

It shows that you can pass a variable in the URL if you make the path to the included file absolute. So, if you were to pass a varible in the url which was something like included=yes, you'd be able to set up your 'includee' to check for that variable, and do somethign differant if it equals yes.

Link to comment
Share on other sites

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.