ProcessWire - Selectors

Aus Wikizone
Wechseln zu: Navigation, Suche

Beispiele

Selektoren in Option Fieldtypes

$optionsfield // return id (string)
$optionsfield->id; // return id (int)
$optionsfield->title; // return string USE THIS or
$optionsfield->value; // return empty string or value (if your option settings like '1=value|title')

// dot syntax in selector string
$pages->find('optionsfield.id=2');

Page Reference auf diese Seite

https://processwire.com/talk/topic/1071-page-fieldtype-two-way-relation/

echo $pages->find("field1=$page")->render();

If the page isn't part of the front-end site, then I'll remove view access from its template. Or if it is part of the front-end, but I don't want to show the relations, then this:

if($page->editable()) echo $pages->find("field1=$page")->render();

Though I almost always integrate these relation-revealing pages into the site structure, as it's rare that this information doesn't have some value to the site's users too. This is an example of one that locates all pages referencing it in a field called 'country':

https://www.tripsite.com/countries/croatia/