desarrollo-cespi / pm-j-s-cook-menu-plugin
symfony 1 插件,封装 JSCookMenu,提供创建菜单的简单方式
dev-master
2013-12-28 16:58 UTC
Requires
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2024-09-24 02:00:17 UTC
README
pmJSCookMenuPlugin
是 JSCookMenu 的包装器。它提供了一种优雅的方式(使用组合设计模式)来创建菜单。
安装
- 使用 Composer 安装
{ "require": { "desarrollo-cespi/pm-j-s-cook-menu-plugin": "dev-master" } }
- 或者从 git 源安装。
使用方法
- 加载 JavaScript 和样式表(IE:ThemePanel)
# in apps/<app>/config/view.yml stylesheets: [main.css, /pmJSCookMenuPlugin/css/ThemePanel/theme.css] javascripts: [/pmJSCookMenuPlugin/js/JSCookMenu.js, /pmJSCookMenuPlugin/js/ThemePanel/theme.js]
- 选择主题(IE:ThemePanel)
// in apps/<app>/templates/layout.php (BEFORE include_javascript call) <script> var myBase = "<?php echo $sf_request->getRelativeUrlRoot() ?>/pmJSCookMenuPlugin/images/ThemePanel/"; var cmBase = myBase; </script>
使用 YAML 文件显示菜单
- 为菜单创建一个 YAML 文件
# in apps/<app>/config/menu.yml (or other file) root: root: true orientation: hbr theme: ThemePanel menu1: title: Start here icon: menu.png #this is found in web/images submenu: # a submenu for menu1 menu1.1: title: go to google url: http://www.google.com menu1.2: title: go to yahoo description: another search engine url: http://www.yahoo.com target: blank menu2: title: some actions submenu: menu2.1: title: Create an object credentials: [some, credentials] url: module/actions _cmSplit: menu2.2: title: another menu url: module/actions
- 显示菜单
// in apps/<app>/templates/layout.php <?php $menu = pmJSCookMenu::createFromYaml(sfConfig::get("sf_app_config_dir")."/menu.yml") ?> <?php echo $menu->render() ?>
- 以编程方式显示菜单
<?php $menu = new pmJSCookMenu() ?> <?php $menu->setTitle("Integrador")?> <?php $menu->setRoot() ?> <?php $menu->setOrientation("hbr") ?> <?php $menu->setTheme("ThemePanel") ?> <?php $menu_item = new pmJSCookMenuItem() ?> <?php $menu_item->setTitle("some module")->setUrl("@some_module") ?> <?php $menu->addChild("som_module", $menu_item) ?> <?php $menu_item = new pmJSCookMenuItem() ?> <?php $menu_item->setTitle("another_module")->setUrl("@another_module") ?> <?php $menu->addChild("another_module", $menu_item) ?> <?php $menu_item = new pmJSCookMenuItem() ?> <?php $menu_item->setTitle("and_another")->setUrl("@and_another") ?> <?php $menu->addChild("and_another", $menu_item) ?> <?php $menu->render() ?>