IntegralHack Posted January 27, 2014 Share Posted January 27, 2014 I would like to have a home page which does nothing but serve as a pointer to another page in the site, but I want that page selectable, as it will change periodically. So in the Home Page template I'd like to use the Page field to select a page that will be used as the Home Page. Seems easy. Right? I think I just need to know what code to put in the template itself. Thanks! Link to comment Share on other sites More sharing options...
kongondo Posted January 27, 2014 Share Posted January 27, 2014 (edited) Hi IntegralHack, Welcome to the forums (it seems you've been using PW for a bit already?)... Your question has two parts: 1. Redirect to another page 2. Use Page Reference Field to select the page to redirect to... For (1), similar question was asked a couple of hours ago (incidentally)..so, I'll just point you to that thread.... http://processwire.com/talk/topic/5413-setting-the-homepage/ For (2), you will just need to tell PW in your template file to redirect to the page selected in the reference field....Does this make sense or you need some code to look at? Similar question answered today here http://processwire.com/talk/topic/5414-selector-find-page-reference-help/ EDIT: Added example code... OK, just in case/for the next guy..... $session->redirect($page->singlePageReferenceField->url); ....where singlePageReferenceField is your, uh,...self-explanatory ;-) Also, note that you can use normal PW selectors to specify the page to redirect from (e.g. if page ID is 123, redirect to.....) in case you want to be more specific [e.g. in cases where a template is used by several pages and you only want to redirect from a specific page(s) and not others...Hope this makes sense... Edited January 27, 2014 by kongondo 2 Link to comment Share on other sites More sharing options...
IntegralHack Posted January 27, 2014 Author Share Posted January 27, 2014 Thank you. Wouldn't redirection change the URL? I guess what I'm really after is to use the contents of the referenced page, sans redirection. In other words, I'd prefer to maintain my http://mydomainname.com without it changing to http://mydomainname.com/internalreferencedpage/ Link to comment Share on other sites More sharing options...
kongondo Posted January 27, 2014 Share Posted January 27, 2014 (edited) Aaaah...I knew there was a catch...Yes, redirect will take you to another URL... There's various ways to get round that. 1. Use render()....I gotta run...I'll explain this later if someone else doesn't or you don't look it up first ;-) - render the whole page being referenced.. 2. $pages->get() [if only interested in a particular field in the page selected via the page reference... EDIT: In addition to the code example by Adrian below Examples in the wiki: http://wiki.processwire.com/index.php/Including_a_page_in_another_page Good to know: http://processwire.com/talk/topic/4367-using-page-renderoptions-and-template-cache/ Edited January 27, 2014 by kongondo 3 Link to comment Share on other sites More sharing options...
adrian Posted January 27, 2014 Share Posted January 27, 2014 Well you could do that by using render in your template: echo $referencedPage->render(); 4 Link to comment Share on other sites More sharing options...
IntegralHack Posted January 28, 2014 Author Share Posted January 28, 2014 Brilliant. Thanks to you both kongondo and adrian! 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