Jump to content

Recommended Posts

Posted

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

Posted

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) {

Posted

What ID are you getting when you echo $pages->get($cityid)? You might want to wrap into quotes like $pages->get("$cityid").

Posted

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.

  • Like 3
Posted

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.

  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...