melissa_boyle Posted December 4, 2014 Share Posted December 4, 2014 Hi Guys, I am trying to create an IF statement that will show text only if the parent exists. I have made a start to but when the page does have the third parent as such it still shows the else statement. Can anyone help please? $parents = $resort->parents; echo $parents[2]->title; if ($resort->has_parent[3]) { echo ", "; echo $parents[3]->title; } else { echo "test"; } Thanks in advance, Mel Link to comment Share on other sites More sharing options...
arjen Posted December 4, 2014 Share Posted December 4, 2014 Not really sure what you are trying to do, since you don't have to check if a parent exists. A parent always exists in ProcessWire. This is how you can check the number of parents. Maybe that will help you out. $parentCount = count($page->parents); if ($parentCount == 2) echo "do something"; 4 Link to comment Share on other sites More sharing options...
melissa_boyle Posted December 4, 2014 Author Share Posted December 4, 2014 Sorry for the confusion this is perfect, Many thanks for your help! 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