thijs Posted May 24, 2013 Share Posted May 24, 2013 Hey all, Did I mention that ever since I started working with PW web development has gone /so/ much faster! I’d like to ask you a question about the following; I’m building a so called ‘one-pager’, a website where all pages are on one single page. I’ve created the page structure in PW as I normally do, and I’m rendering all these pages as sections from one template which I’ve called home. I do want the individual sections to have their own url, and from these urls I’d like to render the home template. Nothing special so far, what I am after is the following: How can I figure out which page rendered the home template? I remember seeing a topic about this, and the possibility of passing an options array to the render() method; http://processwire.com/talk/topic/3145-multiple-views-for-templates/page-2?hl=%2Brender+%2Bcaller#entry32876 Is this functionality only available in the dev branch? Or is there another way of figuring out what page was originally requested? I’m running PW version 2.3.0. Thanks in advance! Thijs Link to comment Share on other sites More sharing options...
Wanze Posted May 24, 2013 Share Posted May 24, 2013 Hi thijs, It's in the dev branch only. So you have two (there are more of course, it's Pw!) solutions: Use the dev version of Pw and get the page that rendered the template with $options['pageStack']. The method ryan mentioned in the post at the end. Before rendering the home template: $home->caller = $page; Then in your home template, you can access the caller page with $page->caller; 3 Link to comment Share on other sites More sharing options...
thijs Posted May 24, 2013 Author Share Posted May 24, 2013 Hi Wanze, Thanks for your reply! I went for option 2 and it works well, great! Link to comment Share on other sites More sharing options...
diogo Posted May 24, 2013 Share Posted May 24, 2013 3. You can also adapt this method http://processwire.com/talk/topic/3551-small-tip-for-pages-that-will-be-used-with-render/ $path = str_replace ($config->urls->root,'/' , $_SERVER["REQUEST_URI"]); // so it works also when pw is in a subfolder $caller = $pages->get($path)->title; just to give more options 2 Link to comment Share on other sites More sharing options...
thijs Posted May 25, 2013 Author Share Posted May 25, 2013 Thanks diogo, always good to know Link to comment Share on other sites More sharing options...
sakkoulas Posted May 31, 2013 Share Posted May 31, 2013 thanks diogo This is what I was looking for 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