Processwire - API

Aus Wikizone
Wechseln zu: Navigation, Suche

Allgemeine Tipps

  • Wenn kein Zugriff auf das Pages Objekt möglich ist kann man über wire()->pages auf die Funktionen zugreifen.

ProcessWire API - Page Manipulation

ProcessWire API - Page Manipulation

ProcessWire API Variable

ProcessWire hat einige nützliche Variablen die man ständig benötigt. Außerdem kann man außer über eine Variable auf viele Objekte auch als Funktion zugreifen. Wichtig sind z.B. folgende Objekte

Page
Pages
Config
Wire
User

Zugriff auf Variablen

Es gibt unterschiedliche Wege mit unterschiedlichen Vor- und Nachteilen auf API Variablen zuzugreifen.

https://processwire.com/docs/start/variables/
$page the most common access as a variable.
page() accessing as a function can be very convenient, when available.
wire('page') This works anywhere, and with any version of ProcessWire.
$this->page This is how you might access it from within a Wire-derived class.
$this->wire('page') A slightly more efficient way you can access from within a Wire-derived class.
$pages->wire('page') API variables can also access all other API variables, by way of their wire() method. In this example, we are accessing the $page API variable from the $pages API variable. So if you have any one API variable, then you actually have them all.

Accessing API variables as a function rather than a variable can be more convenient when the variable version may be out of scope, or if your IDE highlights API variables as undefined. So whenever we refer to an API variable, make note that access it however you'd like.

This is just an introduction to some of ProcessWire's API variables. Once you are familiar with these, you'll want to use ProcessWire's full API reference instead.