Jump to content

Is it possible to search for a repeater item in a specific position?


Jorge
 Share

Recommended Posts

Hi.

I'm trying to accomplish something like this:

$entriesByArea = $admitted->find("areas[0].title='$area', sort=-average, limit=$limit");

I want to find items where the first item of the field areas (a repeater) has the title = $area.
Is this possible in any way?

Thank you.

Link to comment
Share on other sites

You could use a hidden field in the template to store the title of the first repeater item, similar to this:

Or you could match the repeater page by sort position and then get the containing page for each matched repeater page.

$items = $pages->find("template=repeater_areas, title=$area, page.sort=0, check_access=0");
$results = new PageArray();
foreach($items as $item) {
	// Get root page that contains the repeater page
	$result = $item->getForPageRoot();
	// Maybe do some checks on $result page here, for example if you only want pages that have a particular template
	$results->add($result);
}

 

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