Returns a menu item type information. The type information is returned as array
with the following elements:
- references - a list of the item type reference options. The options are returned in the
["key"] => "title" format for options that don't have sub-options, and in the format
["key"] => ["title"=>"Option title", "items"=>[...]] for options that have sub-options. Optional,
required only if the menu item type requires references.
- nesting - Boolean value indicating whether the item type supports nested items. Optional,
false if omitted.
- dynamicItems - Boolean value indicating whether the item type could generate new menu items.
Optional, false if omitted.
- cmsPages - a list of CMS pages (objects of the Cms\Classes\Page class), if the item type requires a CMS page reference to
resolve the item URL.
public static getMenuTypeInfo ( string $type ) : array | ||
$type | string | Specifies the menu item type |
리턴 | array | Returns an array |
public function boot() { /* * Register menu items for the RainLab.Pages plugin */ Event::listen('pages.menuitem.listTypes', function () { return ['blog-category' => 'rainlab.blog::lang.menuitem.blog_category', 'all-blog-categories' => 'rainlab.blog::lang.menuitem.all_blog_categories', 'blog-post' => 'rainlab.blog::lang.menuitem.blog_post', 'all-blog-posts' => 'rainlab.blog::lang.menuitem.all_blog_posts']; }); Event::listen('pages.menuitem.getTypeInfo', function ($type) { if ($type == 'blog-category' || $type == 'all-blog-categories') { return Category::getMenuTypeInfo($type); } elseif ($type == 'blog-post' || $type == 'all-blog-posts') { return Post::getMenuTypeInfo($type); } }); Event::listen('pages.menuitem.resolveItem', function ($type, $item, $url, $theme) { if ($type == 'blog-category' || $type == 'all-blog-categories') { return Category::resolveMenuItem($item, $url, $theme); } elseif ($type == 'blog-post' || $type == 'all-blog-posts') { return Post::resolveMenuItem($item, $url, $theme); } }); }