php Processwire Modules API
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Processwire Modules API相关的知识,希望对你有一定的参考价值。
<?php
// Edit Modules Settings
$old_data = wire('modules')->getModuleConfigData('YOU_MODULE_CLASS');
$new_data = array('development_mode' => '0');
$data = array_merge($old_data, $new_data);
$module = 'YOU_MODULE_CLASS';
wire('modules')->saveModuleConfigData($module, $data);
// Set custom options for page reference field
wire()->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
if($event->object->hasField == 'YOUR_FIELD_NAME') {
$event->return = $event->pages->find("YOUR_CUSTOM_SELECTOR");
}
});
// get module page name
const PAGE_NAME = 'SOME_PAGE_NAME';
self::PAGE_NAME
eg:
$redirectUri .= $config->httpHost . $config->urls->admin . self::PAGE_NAME . '/';
<?php
/**
* Add Custom Button On Page edit
*/
public function addButton(HookEvent $event) {
$url = $event->arguments(0);
$page = $event->object->getPage();
if($page->template == "form-submit") {
$href = $this->config->urls->admin.SELF::MODULE_URL."respond/?id=$page->id";
$field = $this->modules->get('InputfieldButton');
$field->attr('id+name', 'respond');
$field->attr('class', 'uk-button uk-button-primary');
$field->attr('value', "Email to: {$page->name}");
$field->attr('href',$href);
$event->return = $event->return->append($field);
}
}
public function init() {
$this->addHook('ProcessPageEdit::buildForm', $this, 'addButton');
}
以上是关于php Processwire Modules API的主要内容,如果未能解决你的问题,请参考以下文章
php ProcessWire Mail
php ProcessWire管理数据表
php Processwire更改页面创建日期
php Processwire页面URL挂钩
php Processwire表格
php Processwire Google Analytics跟踪