Jump to content

wireRenderFile question about $page


Recommended Posts

I can't believe I've never used wireRenderFile before... So, it all works nicely so far, but I have a basic question:

I am using the function in a parent page to render child pages. Child pages can have various types of templates. In my included file, when I use $page, it referes to the page calling the wireRenderFile function; fair enough, and logical.

Is there a way to check in my included template file if this child page is called directly, or whether it has been included from somewhere else? A simple check, so I can use the template in both scenarios (stand-alone view for just this page, or in cases I use wireRenderFile somewhere else). Right now I am passing the child page's ID like this:

wireRenderFile('my_template', array('pid' => $child->id));

And in my_template, to access it's own page fields, etc. I use

$thisPage = pages()->get($pid);
$myField = $thisPage->foo; // etc.

Is that the way to go, or do I overlook something obvious?

d'oh of course, it's as simple as:

if(isset($pid)) {
    $thisPage = pages()->get($pid); // we get called with wireRenderFile
} else {
    $thisPage = $page; // business as usual


Edited by dragan
a classic: found solution minutes after posting...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...