ProcessWire - Module Snippets

Aus Wikizone
Wechseln zu: Navigation, Suche

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;
}