Skip to content

Instantly share code, notes, and snippets.

@0test
Created August 29, 2019 19:04
Show Gist options
  • Save 0test/b6687fe7b259c2a50a22d94f1302673a to your computer and use it in GitHub Desktop.
Save 0test/b6687fe7b259c2a50a22d94f1302673a to your computer and use it in GitHub Desktop.
Изменяем некоторые иконки в дереве
$e = &$modx->Event;
if($e->name = 'OnManagerNodePrerender'){
/* Разделы каталога */
if($ph['template'] == '6'){
$ph['icon'] = "<i class='fa fa-table'></i>";
$ph['icon_folder_open'] = "<i class='fa fa-table'></i>";
$ph['icon_folder_close'] = "<i class='fa fa-table'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Раздел каталога"
),
'item3' => array(
'innerHTML' => '<i class="fa fa-plus fa-fw fa-lg"></i> Добавить раздел или товар',
'id' => 'item3',
'onclick' => "modx.tree.menuHandler(3);"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/* товары */
if($ph['template'] == '7'){
$ph['icon'] = "<i class='fa fa-circle'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Страница товара"
),
'item7' => array(
'innerHTML' => '<i class="fa fa-clone fa-fw fa-lg"></i> Копировать',
'id' => 'item7',
'onclick' => "modx.tree.menuHandler(7);",
),
'item4' => array(
'innerHTML' => '<i class="fa fa-clone fa-fw fa-lg"></i> Удалить',
'id' => 'item4',
'onclick' => "modx.tree.menuHandler(4);",
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
),
'item_plugin_vkpost' => array(
'innerHTML' => '<i class="fa fa-vk fa-fw fa-lg"></i> Залить в ВК',
'id' => 'item12',
'onclick' => "
console.log('Запостить товар №".$ph['id']."');
modx.popup({url:'index.php?a=26', title:' Запостили в ВК', icon: 'fa-vk', iframe: 'ajax', selector: '.tab-page>.container', position: 'center top', width: 'auto', maxheight: '50%', wrap: 'body',hide: 0,hover:1 })
",
)
);
}
/* блог главная */
if($ph['template'] == '8'){
$ph['icon'] = "<i class='fa fa-book'></i>";
$ph['icon_folder_open'] = "<i class='fa fa-book'></i>";
$ph['icon_folder_close'] = "<i class='fa fa-book'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Главная страница блога"
),
'item3' => array(
'innerHTML' => '<i class="fa fa-plus fa-fw fa-lg"></i> Добавить пост',
'id' => 'item3',
'onclick' => "modx.tree.menuHandler(3);"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/* блог пост */
if($ph['template'] == '12'){
$ph['icon'] = "<i class='fa fa-edit'></i>";
$ph['icon_folder_open'] = "<i class='fa fa-edit'></i>";
$ph['icon_folder_close'] = "<i class='fa fa-edit'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Пост"
),
'item7' => array(
'innerHTML' => '<i class="fa fa-clone fa-fw fa-lg"></i> Копировать',
'id' => 'item7',
'onclick' => "modx.tree.menuHandler(7);",
),
'item4' => array(
'innerHTML' => '<i class="fa fa-clone fa-fw fa-lg"></i> Удалить',
'id' => 'item4',
'onclick' => "modx.tree.menuHandler(4);",
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/*Главная*/
if($ph['id'] == '1'){
$ph['icon'] = "<i class='fa fa-home'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Стартовая страница сайта"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/*sitemap.xml*/
if($ph['id'] == '34'){
$ph['icon'] = "<i class='fa fa-sitemap'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "XML карта"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/*404*/
if($ph['template'] == '17'){
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Страница ошибки 404"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
/* теги блога*/
if($ph['id'] == '27'){
$ph['icon'] = "<i class='fa fa-tag'></i>";
$ph['icon_folder_open'] = "<i class='fa fa-tag'></i>";
$ph['icon_folder_close'] = "<i class='fa fa-tag'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Теги"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
//аккаунт и т.п
if($ph['id'] == '28' || $ph['id'] == '29'){
$ph['icon'] = "<i class='fa fa fa-money'></i>";
$ph['contextmenu'] = array(
'header1' => array(
'innerText' => "Страницы пользователей"
),
'item12' => array(
'innerHTML' => '<i class="fa fa-eye fa-fw fa-lg"></i> Показать на сайте',
'id' => 'item12',
'onclick' => "modx.tree.menuHandler(12);",
)
);
}
}
$e->output(serialize($ph));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment