Jump to content
regesh

Difficult params for find()

Recommended Posts

Can anyone tell me how to find pages in propper way))
Now i solved taks like this
 

//$place = 1036
//$type = 1122
//doctors_office = page field with multiselect by checkbox
//direction_category  = page field with select field for one value can be choosen

 foreach ($pages->find("template=doctor") as $doc) {
	 	foreach($doc->doctors_office as $item) {
		  if($item->id == $place){
		  	if($doc->direction_category->id == $type){
		  		$list[] = $doc->title;
		  	}
		  }
		}

 

Share this post


Link to post
Share on other sites

For a front-end search form?

One strategy I often use is concatenating the selector one input field at a time. Just make sure your add your validation.

Something like this:

$selector = '';

if($place = sanitizer()->selectorValue($input->post->place)) {

    $input->whitelist('place', $place);

    $selector .= ", place%=$place";
}

if($input->post->doctor) {

    $input->whitelist('doctor', $input->post->doctor);

    if($input->post->doctor == '1') {
        $selector .= ", name=jim";
    } elseif($input->post->doctor == '2') {
        $selector .= ", name=jon";
    } elseif($input->post->doctor == '3') {
        $selector .= ", name=jake";
    }
}

$limit = 12;
$template = doctor;
$parent = doctors;

$selector .= ", sort=sort, limit=$limit";
$selector = "template=$template, parent=$parent" . $selector;

$results = pages()->find->($selector);

 

  • Like 3

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...