Chris Rosenau Posted January 4, 2014 Share Posted January 4, 2014 I am getting the page ID and I tried to do this: $cityid=$children->co_cities;echo $pages->get($cityid)->title; But it just displays Home, instead of the city name. Anyone have any idea what I am doing wrong? Chris Link to comment Share on other sites More sharing options...
kongondo Posted January 4, 2014 Share Posted January 4, 2014 I'm a bit confused by your code. Where did you define $children? Is it an array or a single variable? Link to comment Share on other sites More sharing options...
Chris Rosenau Posted January 4, 2014 Author Share Posted January 4, 2014 It is in a for loop that pulls each state. Each listing in the state has a field assigned with a city page. All listings are located as children of the state page. foreach ($pages->get("/states/".$myloc[state]."/")->children as $children) { Link to comment Share on other sites More sharing options...
arjen Posted January 4, 2014 Share Posted January 4, 2014 What ID are you getting when you echo $pages->get($cityid)? You might want to wrap into quotes like $pages->get("$cityid"). Link to comment Share on other sites More sharing options...
Chris Rosenau Posted January 4, 2014 Author Share Posted January 4, 2014 Thanks that was my problem. Link to comment Share on other sites More sharing options...
Soma Posted January 4, 2014 Share Posted January 4, 2014 Look cumbersome to me cause $cityid is not the id but the page object. So $cityid->title would be enough. No reason to get the page again. If you echo $cityid you will get the ID because of the __toString() method but in fact it's really a page. 3 Link to comment Share on other sites More sharing options...
Soma Posted January 4, 2014 Share Posted January 4, 2014 Or simply $children->co_cities->title. Although the naming seems wrong because it seems it's not children but a child and the field is a single page select? So it should be co_city. 1 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