Jump to content

Recommended Posts

Posted

I have a template which makes use of the page reference field and am able to reference fields as so...

$places = $wire->pages->find('template=pageGeo');

foreach($places as $place){
	//geo_type is a page field getting pages I have stored in the admin folder
	//checking if the name of the page reference in this way works
	if($place->geo_type->name == 'geo-province')
	{
		echo 'this is a province';
	}
}

I have another template that also makes use of the page reference field but this won't return anything except the page id

//this doesn't return anything
echo $page->party_type->title;

seems the only way to get it to return the title is as follows:

$id = $page->party_type;
echo $pages->get('id='.$id)->title;
//this returns "birthday"

party_type also refers to pages that are found within the admin folder

Both fields refer to pages I keep in the admin folder.

So what am I missing?

Posted

If you use Tracy you could also dump the object like:

bd($page->party_type);

It'll save you much time if you know what kind of data you are working on.

  • Like 2

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...