Chris Rosenau Posted January 4, 2014 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
kongondo Posted January 4, 2014 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?
Chris Rosenau Posted January 4, 2014 Author 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) {
arjen Posted January 4, 2014 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").
Soma Posted January 4, 2014 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
Soma Posted January 4, 2014 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
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