Jump to content

Get Page only if given ID is first in PageFieldMultiple


Torsten Baldes
 Share

Recommended Posts

Hi,

i'm looking for a way/selector to get all pages which have a pagefield with multiple selected pages (think tags), but only if the first page in this pagefield matches the given id.

My selector looks like this right now:

$pages->find('template=trip, tripdata_category='.$page);

This gets me all the trips which have the current category at any position in the pagefield tripdata_category .

But what i want is, to get only the trips which have this category at the first position in this pagefield.

Is this possible with a selector or do i have to filter the results in some way?

 

Thanks!

Link to comment
Share on other sites

My suggestion

$temp = $pages->find('template=trip, tripdata_category='.$page);
$trips = new PageArray();
foreach($temp as $tp) {
	if($tp->tripdata_category->first() == $page) $trips->add($tp); 
}

 

  • Like 3
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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