Jump to content

$page->getArray() and field type Page references


Recommended Posts

Posted

I have many pages with multiple Page fieldtypes.
What I'm looking at doing is caching the related pages, however I cannot obtain ID references via $page->getArray(). I only get [title] returned. Is there a way to return Page typefield field ID references to other pages without hitting the DB?

Posted

In ProcessWire 3.x (I think only 3?) you can use implode like so:

$pageIDsString = $yourPageArray->implode('|', 'id');
//echo $pageIDsString;// returns 1234|2345|8976 etc..

You can choose your delimiter and the property to implode by. There's other interesting methods here.

 

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