ProcessWire - Page Reference (Field): Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
Zeile 10: Zeile 10:
 
  // usage with all arguments
 
  // usage with all arguments
 
  $items = $page->references($selector = '', $field = '');
 
  $items = $page->references($selector = '', $field = '');
 +
 +
=== Erstelle Seitenreferenzen ===
 +
 +
$myPage->pReferences = $page; // creates one reference
 +
$myPage->save(); // make sure to save page somewhere
 +
 +
This of course doesn't work with multiple pages. I tried this (found from current docs, used in images):
 +
 +
$myPage->pReferences->add($page); // adds a page reference, allows more than one add (if field allows this).
 +
$myPage->save();

Version vom 25. Januar 2019, 10:46 Uhr

Page Reference Felder enthalten Verbindungen zu anderen Seiten.

API Zugriff auf Page Reference

Finde Seiten die auf Diese zeigen

https://processwire.com/api/ref/page/references/

Available since version 3.0.107.

// basic usage
$items = $page->references();
// usage with all arguments
$items = $page->references($selector = , $field = );

Erstelle Seitenreferenzen

$myPage->pReferences = $page; // creates one reference
$myPage->save(); // make sure to save page somewhere

This of course doesn't work with multiple pages. I tried this (found from current docs, used in images):

$myPage->pReferences->add($page); // adds a page reference, allows more than one add (if field allows this).
$myPage->save();