Jump to content

How Can I Do This?


OllieMackJames
 Share

Recommended Posts

Can anyone tell me what to change in the code below so it works again, this code used to work up until I think PW 3.148, sometime after that it just stopped working
What it should do is this:

- if the page is the homepage, and the Pagefield page2use4homepage is filled, then use the id of the page2use4homepage to pull data from to show in frontend for homepage

if ($page->id === 1 && $page->page2use4homepage) {
    $page = $page->page2use4homepage;
}

If I just use the following code directly it works fine:

$page = $pages(1771);

Thanks!

Link to comment
Share on other sites

The field page2use4homepage will return a null page (id = 0) if no page is selected, which might be confusing things.

I haven't tested, but I'd suggest using:

(($page->id == 1) && ($page->page2use4homepage->id != 0))

 

Link to comment
Share on other sites

18 hours ago, BillH said:

The field page2use4homepage will return a null page (id = 0) if no page is selected, which might be confusing things.

I haven't tested, but I'd suggest using:


(($page->id == 1) && ($page->page2use4homepage->id != 0))

 

Thanks for your thinking along, but that did not work either.

Funny thing is that this code used to work with I think PW 3.148, sometime after that it just stopped working

Link to comment
Share on other sites

19 minutes ago, kongondo said:

Is there a reason you are overwriting the API variable $page?

Yes, I use this for the homepage only, which now can be easily filled with the content of another - unpublished - page

Used to work like a charm, but ever since one of the updates since 3.148 I think it was it no longer works

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...