heyday/silverstripe-menumanager
Composer 安装命令:
composer require heyday/silverstripe-menumanager
包简介
Allows complex menu management to be handled through the CMS when a simple tree structure is not enough.
README 文档
README
The menu management module is for creating custom menu structures when the site tree hierarchy just won't do.
Installation
composer require heyday/silverstripe-menumanager
After completing this step, navigate in Terminal or similar to the SilverStripe
root directory and run composer install or composer update depending on
whether or not you have composer already in use.
Usage
There are 2 main steps to creating a menu using menu management.
- Create a new MenuSet
- Add MenuItems to that MenuSet
Creating a MenuSet
Login to the CMS and open the Menus admin, give the MenuSet a Name (which is
what you reference in the templates when controlling the menu).
As it is common to reference MenuSets by name in templates, you can configure sets to be created automatically during the /dev/build task. These sets cannot be deleted through the CMS.
Heyday\MenuManager\MenuSet: default_sets: - Main - Footer
Creating MenuItems
Once you have saved your MenuSet you can add MenuItems.
MenuItems have 4 important fields:
- Page
- MenuTitle
- Link
- IsNewWindow
Page
A page to associate your MenuItem with.
MenuTitle
This field can be left blank if you link the menu item with a page. If not fill with the title you want to display in the template.
Link
This field can be left blank unless you want to link to an external website. When left blank using $Link in templates will automatically pull the link from the MenuItems associated Page. If you enter a link in this field and then pick a Page as well the link will be overwritten by the Page you chose.
IsNewWindow
Can be used as a check to see if 'target="_blank"' should be added to links.
Disable creating Menu Sets in the CMS
Sometimes the defined default_sets are all the menu's a project needs. You can
disable the ability to create new Menu Sets in the CMS:
Heyday\MenuManager\MenuAdmin: enable_cms_create: false
Note: Non-default Menu Sets can still be deleted, to help tidy unwanted CMS content.
Usage in template
<% loop $MenuSet('YourMenuName').MenuItems %> <a href="{$URL}" class="{$LinkingMode}">{$MenuTitle}</a> <% end_loop %>
To loop through all MenuSets and their items:
<% loop $MenuSets %> <% loop $MenuItems %> <a href="{$URL}" class="{$LinkingMode}">{$MenuTitle} </a> <% end_loop %> <% end_loop %>
Optionally you can also limit the number of MenuSets and MenuItems that are looped through.
The example below will fetch the top 4 MenuSets (as seen in Menu Management), and the top 5 MenuItems for each:
<% loop $MenuSets.Limit(4) %> <% loop $MenuItems.Limit(5) %> <a href="{$URL}" class="{$LinkingMode}">{$MenuTitle}</a> <% end_loop %> <% end_loop %>
Enabling partial caching
Partial caching can be enabled with your menu to speed up rendering of your templates.
<% with $MenuSet('YourMenuName') %> <% cached 'YourMenuNameCacheKey', $LastEdited, $MenuItems.max('LastEdited'), $MenuItems.count %> <% if $MenuItems %> <nav> <% loop $MenuItems %> <a href="{$URL}" class="{$LinkingMode}"> $MenuTitle.XML </a> <% end_loop %> </nav> <% end_if %> <% end_cached %> <% end_with %>
Allow sorting of MenuSets
By default menu sets cannot be sorted, however, you can set your configuration to allow it.
Heyday\MenuManager\MenuSet: allow_sorting: true
Subsite Support
If you're using SilverStripe Subsites, you can make MenuManager subsite aware via applying an extension to the MenuSet.
app/_config/menus.yml
Heyday\MenuManager\MenuSet: create_menu_sets_per_subsite: true extensions: - Heyday\MenuManager\Extensions\MenuSubsiteExtension Heyday\MenuManager\MenuItem: extensions: - Heyday\MenuManager\Extensions\MenuSubsiteExtension
License
Menu Manager is licensed under an MIT license
heyday/silverstripe-menumanager 适用场景与选型建议
heyday/silverstripe-menumanager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 312.77k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2013 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 heyday/silverstripe-menumanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 heyday/silverstripe-menumanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 312.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 24
- 依赖项目数: 13
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2013-06-10