OnManagerPageBeforeRender
Последнее обновление Jan 28th, 2020 | История страницы | Улучшить эту страницу | Сообщить о проблеме
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moreСобытие: OnManagerPageBeforeRender¶
Событие запускается в контроллере менеджера перед обработкой контента.
- Служба: 2 - Manager Access Events
- Group: System
Параметры события¶
| Имя | Описание |
|---|---|
| controller | Экземпляр контроллера текущей страницы менеджера. |
Примечания¶
| Предыдущее событие | OnBeforeManagerPageInit |
|---|---|
| Следующее событие | OnManagerPageAfterRender |
| Файл | core/src/Revolution/modManagerController.php |
| Класс | abstract class modManagerController |
| Метод | public function render() |
Пример¶
Такой плагин выведет в журнал ошибок, какой контроллер запущен:
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnManagerPageBeforeRender':
// какой контроллер загружается
print_r($scriptProperties['controller']->config);
print_r($scriptProperties['controller']->scriptProperties);
break;
}
Запретить редактирование ресурса, чей id отсутствует в настройке allow_to_update:
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnManagerPageBeforeRender':
$controller = $scriptProperties['controller'];
if ($controller->config['controller'] !== 'resource/update') {
break;
}
$allow_to_update = $modx->getOption('allow_to_update');
if (empty($allow_to_update)) {
break;
}
if (!is_array($allow_to_update)) {
$allow_to_update = array_map('trim', explode(',', $allow_to_update));
}
if (!in_array($controller->scriptProperties['id'], $allow_to_update)) {
$controller->failure('Access is denied');
}
break;
}
Такой плагин подключит нужный нам js на страницы админки:
<?php
$eventName = $modx->event->name;
switch($eventName) {
case 'OnManagerPageBeforeRender':
$modx->controller->addJavascript('url/file.js');
break;
}
Смотри также¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










