resolveMenuItem() 공개 정적인 메소드

Returns information about a menu item. The result is an array with the following keys: - url - the menu item URL. Not required for menu item types that return all available records. The URL should be returned relative to the website root and include the subdirectory, if any. Use the Url::to() helper to generate the URLs. - isActive - determines whether the menu item is active. Not required for menu item types that return all available records. - items - an array of arrays with the same keys (url, isActive, items) + the title key. The items array should be added only if the $item's $nesting property value is TRUE.
public static resolveMenuItem ( RainLab\Pages\Classes\MenuItem $item, string $url, Cms\Classes\Theme $theme ) : mixed
$item RainLab\Pages\Classes\MenuItem Specifies the menu item.
$url string Specifies the current page URL, normalized, in lower case The URL is specified relative to the website root, it includes the subdirectory name, if any.
$theme Cms\Classes\Theme Specifies the current theme.
리턴 mixed Returns an array. Returns null if the item cannot be resolved.
예제 #1
0
 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);
         }
     });
 }