ProcessWire - Module Snippets: Unterschied zwischen den Versionen
Aus Wikizone
(Die Seite wurde neu angelegt: „Nützliche Snippets für das Schreiben von Modulen == Testen ob ein bestimmtes Modul installiert ist == <syntaxhighlight lang="php"> if (!$this->modules->isIn…“) |
|||
| Zeile 8: | Zeile 8: | ||
} | } | ||
$this->tasker = $this->modules->get('Tasker'); | $this->tasker = $this->modules->get('Tasker'); | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | == Selektoren == | ||
| + | === Einfacher Selector Check === | ||
| + | <syntaxhighlight lang="php"> | ||
| + | // check the page selector | ||
| + | if (strlen($selector)<2 || !strpos($selector, '=')) { | ||
| + | $this->error("ERROR: invalid page selector '{$selector}' found in the input."); | ||
| + | return false; | ||
| + | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Version vom 6. Januar 2020, 08:10 Uhr
Nützliche Snippets für das Schreiben von Modulen
Testen ob ein bestimmtes Modul installiert ist
if (!$this->modules->isInstalled('Tasker')) {
$this->message('Tasker module is missing. Install it before using Dataset module.');
return;
}
$this->tasker = $this->modules->get('Tasker');
Selektoren
Einfacher Selector Check
// check the page selector
if (strlen($selector)<2 || !strpos($selector, '=')) {
$this->error("ERROR: invalid page selector '{$selector}' found in the input.");
return false;
}