ProcessWire - Selectors: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „== Beispiele == === Selektoren in Option Fieldtypes === <syntaxhighlight lang="php"> $optionsfield // return id (string) $optionsfield->id; // return id (int)…“)
 
Zeile 10: Zeile 10:
 
$pages->find('optionsfield.id=2');
 
$pages->find('optionsfield.id=2');
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
=== 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/

Version vom 21. August 2018, 17:40 Uhr

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/