dragan Posted February 20, 2019 Share Posted February 20, 2019 (edited) 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 February 20, 2019 by dragan a classic: found solution minutes after posting... Link to comment Share on other sites More sharing options...
adrian Posted February 20, 2019 Share Posted February 20, 2019 Glad you got it sorted. Just thought I'd mention that in addition to the procedural wireRender() file, we also have $files->render() https://processwire.com/api/ref/wire-file-tools/render/ 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now