OnManagerNodePrerender MODX Evo ✈ Evolution CMS
- Виджеты
- OnManagerNodePrerender
Поддержать: USDT TRC20: TBGKTYDs4yzU17vQbobbUB8epFFtFb6PKh
2421
OnManagerNodePrerender MODX Evo ✈ Evolution CMS
Изменение документов в дереве а так же контекстного меню
С помощью этой функции вы можете изменить поведение и внешний вид ресурсов в дереве, изменить значок, нажмите на кнопку, чтобы перейти к модулю (например, вы можете легко реализовать функциональность коллекций из MODX революции), вы также можете изменить контекстное меню, которое было бы более понятным, например, в разделе новостей стандартного контекстного меню место для отображения: добавить новости, все новости.
$e = &$modx->Event;
switch($e->name){
case 'OnManagerNodePrerender':
if($ph['id'] == '2'){
//Change icons for doc with id 2
$ph['icon'] = "";
$ph['icon_folder_open'] = "";
$ph['icon_folder_close'] = "";
$modx->logEvent(123, 1, '- '.print_r($ph, true).' -
', 'ph info'. $ph['id']);
}
if($ph['id'] == '15'){
//Hide child documents + change the icon + write to the variable variables m ph that would look what you can change
$ph['icon'] = "";
$ph['icon_folder_open'] = "";
$ph['icon_folder_close'] = "";
$ph['showChildren'] = '0';
$ph['tree_page_click'] = 'index.php?a=3&id='.$ph['id'].'&tab=1';
//Its custom menu for example took a standard that would be understandable what to change
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => $ph['nodetitle'],
),
'item3' => array(
'innerHTML' => ' Child resource',
'title' => 'Child resource',
'id' => 'item3',
'onclick' => "modx.tree.menuHandler(3);",
),
'item2' => array(
'innerHTML' => ' Edit',
'title' => 'Edit',
'id' => 'item2',
'onclick' => "modx.tree.menuHandler(2);",
),
'item5' => array(
'innerHTML' => ' Move',
'title' => 'Move',
'id' => 'item5',
'onclick' => "modx.tree.menuHandler(5);",
),
'item7' => array(
'innerHTML' => ' Make a copy',
'title' => 'Make a copy',
'id' => 'item7',
'onclick' => "modx.tree.menuHandler(7);",
),
'item11' => array(
'innerHTML' => ' Sort by menu item',
'title' => 'Sort by menu item',
'id' => 'item11',
'onclick' => "modx.tree.menuHandler(11);",
),
'seperator' => '',
'item9' => array(
'innerHTML' => ' Publish',
'title' => 'Publish',
'id' => 'item9',
'onclick' => "modx.tree.menuHandler(9);",
),
'item10' => array(
'innerHTML' => ' Unpublish',
'title' => 'Unpublish',
'id' => 'item10',
'onclick' => "modx.tree.menuHandler(10);",
),
'item4' => array(
'innerHTML' => ' Uninstall',
'title' => 'Uninstall',
'id' => 'item4',
'onclick' => "modx.tree.menuHandler(4);",
),
'item8' => array(
'innerHTML' => ' Restore',
'title' => 'Restore',
'id' => 'item8',
'onclick' => "modx.tree.menuHandler(8);",
),
'seperator2' => '',
'item6' => array(
'innerHTML' => ' Child Web Reference',
'title' => 'Child Web Reference',
'id' => 'item6',
'onclick' => "modx.tree.menuHandler(6);",
),
'seperator3' => '',
'item1' => array(
'innerHTML' => ' All goods',
'title' => 'All goods',
'id' => 'item1',
'onclick' => "modx.tree.menuHandler(1);",
),
'item12' => array(
'innerHTML' => ' Look inside',
'title' => 'Look inside',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
),
'seperator4' => '',
'item100' => array(
'innerHTML' => ' Example of your item',
'title' => 'Title',
'id' => 'item1',
'onclick' => "main.location.href='/'",
),
'image2' => array(
'innerHTML' => '
'
)
);
// Don't forget to check if the resource is published. The link publish does not make sense as well as sorting the items if it is not a folder.
if ($ph['isfolder']=='0') unset($ph['contextmenu']['item11']);
if ($ph['deleted']=='0') unset($ph['contextmenu']['item8']);
if ($ph['deleted']=='1') unset($ph['contextmenu']['item4']);
if ($ph['published']=='0') unset($ph['contextmenu']['item10']);
if ($ph['published']=='1') unset($ph['contextmenu']['item9']);
}
$modx->event->output(serialize($ph));
break;
}