Jump to content

Home page as Pointer to another page within the site


IntegralHack
 Share

Recommended Posts

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

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 by kongondo
  • Like 2
Link to comment
Share on other sites

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 by kongondo
  • Like 3
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
 Share

  • Recently Browsing   0 members

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