OllieMackJames Posted October 1, 2020 Share Posted October 1, 2020 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 More sharing options...
BillH Posted October 1, 2020 Share Posted October 1, 2020 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 More sharing options...
OllieMackJames Posted October 2, 2020 Author Share Posted October 2, 2020 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 More sharing options...
kongondo Posted October 2, 2020 Share Posted October 2, 2020 On 10/1/2020 at 12:47 PM, OllieMackJames said: $page = $page->page2use4homepage; Is there a reason you are overwriting the API variable $page? Link to comment Share on other sites More sharing options...
OllieMackJames Posted October 2, 2020 Author Share Posted October 2, 2020 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 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