Process Module (ProcessWire): Unterschied zwischen den Versionen
Aus Wikizone
| Zeile 53: | Zeile 53: | ||
</pre> | </pre> | ||
| + | |||
| + | == Felder für Modul Settings hinzufügen == | ||
| + | Beispiel aus dem ProcessHello Modul | ||
| + | |||
| + | ProcessHello.config.php | ||
| + | <syntaxhighlight lang="php"> | ||
| + | <?php | ||
| + | |||
| + | /** | ||
| + | * Configure the Hello World module | ||
| + | * | ||
| + | * This type of configuration method requires ProcessWire 2.5.5 or newer. | ||
| + | * For backwards compatibility with older versions of PW, you'll want to | ||
| + | * instead want to look into the getModuleConfigInputfields() method, which | ||
| + | * is specified with the .module file. So we are assuming you only need to | ||
| + | * support PW 2.5.5 or newer here. | ||
| + | * | ||
| + | * For more about configuration methods, see here: | ||
| + | * http://processwire.com/blog/posts/new-module-configuration-options/ | ||
| + | * | ||
| + | * | ||
| + | */ | ||
| + | |||
| + | class ProcessHelloConfig extends ModuleConfig { | ||
| + | |||
| + | public function __construct() { | ||
| + | |||
| + | $this->add(array( | ||
| + | |||
| + | // Text field: greeting | ||
| + | array( | ||
| + | 'name' => 'greeting', // name of field | ||
| + | 'type' => 'text', // type of field (any Inputfield module name) | ||
| + | 'label' => $this->_('Hello Greeting'), // field label | ||
| + | 'description' => $this->_('What would you like to say to people using this module?'), | ||
| + | 'required' => true, | ||
| + | 'value' => $this->_('A very happy hello world to you.'), // default value | ||
| + | ), | ||
| + | |||
| + | // Radio buttons: greetingType | ||
| + | array( | ||
| + | 'name' => 'greetingType', | ||
| + | 'type' => 'radios', | ||
| + | 'label' => $this->_('Greeting Type'), | ||
| + | 'options' => array( | ||
| + | // options array of value => label | ||
| + | 'message' => $this->_('Message'), | ||
| + | 'warning' => $this->_('Warning'), | ||
| + | 'error' => $this->_('Error'), | ||
| + | ), | ||
| + | 'value' => 'warning', // default value | ||
| + | 'optionColumns' => 1, // make options display on one line | ||
| + | 'notes' => $this->_('Choose wisely'), // like description but appears under field | ||
| + | ) | ||
| + | )); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | </syntaxhighlight> | ||
Version vom 6. Januar 2020, 15:31 Uhr
ProcessWire - Module schreiben https://github.com/ryancramerdesign/ProcessHello/blob/master/ProcessHello.info.php - Beispiel Process Modul
Process Module erweitern die Funktionalität im Admin Bereich.
Dafür gibt es einige spezielle Möglichkeiten.
Admin Bereich anpassen
Seiten im Admin Hinzufügen
Geht über die getModuleInfo Funktion oder über die MeinModul.Info.php Konfigurationsdatei (siehe Beispiel Modul)
// page that you want created to execute this module 'page' => array( 'name' => 'helloworld', 'parent' => 'setup', 'title' => 'Hello World' ),
Wie bei zusätzlicher Seite
// optional extra navigation that appears in admin // if you change this, you'll need to a Modules > Refresh to see changes 'nav' => array( array( 'url' => '', 'label' => 'Hello', 'icon' => 'smile-o', ), array( 'url' => 'something/', 'label' => 'Something', 'icon' => 'beer', ), )
Man kann auch die Option
'useNavJSON' => true,
setzen, dann kann man über die Funktion
public function ___executeNavJSON(array $options = array())
aufwändigere Dinge realisieren (Beispiel in Adrians ProcessAdminActions)
Zugriff regeln
Ebenso lassen sich Permissions definieren
// name of permission required of users to execute this Process (optional) 'permission' => 'helloworld', // permissions that you want automatically installed/uninstalled with this module (name => description) 'permissions' => array( 'helloworld' => 'Run the HelloWorld module' ),
Felder für Modul Settings hinzufügen
Beispiel aus dem ProcessHello Modul
ProcessHello.config.php
<?php
/**
* Configure the Hello World module
*
* This type of configuration method requires ProcessWire 2.5.5 or newer.
* For backwards compatibility with older versions of PW, you'll want to
* instead want to look into the getModuleConfigInputfields() method, which
* is specified with the .module file. So we are assuming you only need to
* support PW 2.5.5 or newer here.
*
* For more about configuration methods, see here:
* http://processwire.com/blog/posts/new-module-configuration-options/
*
*
*/
class ProcessHelloConfig extends ModuleConfig {
public function __construct() {
$this->add(array(
// Text field: greeting
array(
'name' => 'greeting', // name of field
'type' => 'text', // type of field (any Inputfield module name)
'label' => $this->_('Hello Greeting'), // field label
'description' => $this->_('What would you like to say to people using this module?'),
'required' => true,
'value' => $this->_('A very happy hello world to you.'), // default value
),
// Radio buttons: greetingType
array(
'name' => 'greetingType',
'type' => 'radios',
'label' => $this->_('Greeting Type'),
'options' => array(
// options array of value => label
'message' => $this->_('Message'),
'warning' => $this->_('Warning'),
'error' => $this->_('Error'),
),
'value' => 'warning', // default value
'optionColumns' => 1, // make options display on one line
'notes' => $this->_('Choose wisely'), // like description but appears under field
)
));
}
}