mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 17:24:46 +02:00
Improvements to $pages->findRaw() based on requests. Added support getting "parent.field" and "parent.parent.field", etc. Added support for "references" and "references.field", etc. which returns matches from pages referencing the found pages via page reference fields (optionally include 'references.field' in requested fields list to index references by field name). Added support for FieldtypeOptions fields so that they can now return label, value, id or any of them by adding "your_options_field.label" (for example) in your requested $fields. Added new "flat" option which makes it returned flattened arrays for each page match... when used results are indexed in the same way they are requested, for example a result like [ 'page_field' => [ 'title' => 'Some title' ]] becomes [ 'page_field.title' => 'Some title' ]. Added support for requesting field 'meta' and 'meta.name' which returns Page meta data that you would usually access from $page->meta('name'). A few of these requests came from processwire/processwire-requests#427
This commit is contained in:
@@ -2699,8 +2699,9 @@ class PageFinder extends Wire {
|
||||
}
|
||||
$this->parent_id = null;
|
||||
if($isParent) {
|
||||
if($operator === '=') $IDs = $values;
|
||||
$field = 'parent_id';
|
||||
if(count($values) == 1 && count($fields) == 1 && $selector->operator() === '=') {
|
||||
if(count($values) == 1 && count($fields) == 1 && $operator === '=') {
|
||||
$this->parent_id = reset($values);
|
||||
}
|
||||
}
|
||||
@@ -2747,7 +2748,7 @@ class PageFinder extends Wire {
|
||||
$field = $subfield;
|
||||
}
|
||||
}
|
||||
} else if($field === 'id' && count($values) > 1 && $selector->operator === '=' && !$selector->not) {
|
||||
} else if($field === 'id' && count($values) > 1 && $operator === '=' && !$selector->not) {
|
||||
$IDs = $values;
|
||||
|
||||
} else {
|
||||
@@ -2776,7 +2777,7 @@ class PageFinder extends Wire {
|
||||
// convert templates specified as a name to the numeric template ID
|
||||
// allows selectors like 'template=my_template_name'
|
||||
$field = 'templates_id';
|
||||
if(count($values) == 1 && $selector->operator() === '=') $this->templates_id = reset($values);
|
||||
if(count($values) == 1 && $operator === '=') $this->templates_id = reset($values);
|
||||
if(!ctype_digit("$value")) $value = (($template = $this->templates->get($value)) ? $template->id : 0);
|
||||
|
||||
} else if(in_array($field, array('created', 'modified', 'published'))) {
|
||||
|
Reference in New Issue
Block a user