-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlugin.php
55 lines (48 loc) · 1.75 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php namespace Msof\Portfolio;
use System\Classes\PluginBase;
use Event;
use Backend;
class Plugin extends PluginBase
{
public function registerComponents()
{
return [
'Msof\Portfolio\Components\PortfolioList' => 'PortfolioList'
];
}
public function boot()
{
// 01. Add main menu item
Event::listen('backend.menu.extendItems', function($manager) {
$manager->addMainMenuItems('October.Cms', [
'frontend_theme' => [
'label' => 'Frontend Theme',
'url' => Backend::url('cms/themeoptions/update'),
'icon' => 'icon-image',
'permissions' => ['cms.manage_themes', 'cms.manage_theme_options']
]
]);
});
// 02. Add models to a RainLab.Sitemap or RainLab.Pages menu
Event::listen('pages.menuitem.listTypes', function () {
return [
'all-portfolio-projects' => 'All portfolio projects',
];
});
Event::listen('pages.menuitem.getTypeInfo', function ($type) {
if ($type === 'all-portfolio-projects') {
$theme = \Cms\Classes\Theme::getActiveTheme();
$pages = \Cms\Classes\Page::listInTheme($theme, true);
return [
'dynamicItems' => true,
'cmsPages' => $pages,
];
}
});
Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) {
if ($type === 'all-portfolio-projects') {
return Project::resolveMenuItem($item, $url, $theme);
}
});
}
}