desarrollo-cespi/pm-j-s-cook-menu-plugin

symfony 1 plugin that wraps JSCookMenu and provides an easy way of creating menues

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 0

Open Issues: 0

Language:JavaScript

Type:symfony1-plugin

dev-master 2013-12-28 16:58 UTC

This package is not auto-updated.

Last update: 2024-12-17 02:59:17 UTC


README

The pmJSCookMenuPlugin is a wrapper for JSCookMenu. It provides a nice way (using the Composite Design Pattern) for creating menues.

Installation

{
  "require": {
    "desarrollo-cespi/pm-j-s-cook-menu-plugin": "dev-master"
  }
}
  • Or install from git source.

Usage

  • Load javascript an stylesheets (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]
  • Select the theme (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>

Display a menu using a yaml file:

  • Create a yaml file for the menu
# 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
  • Display the menu
// in apps/<app>/templates/layout.php
<?php $menu = pmJSCookMenu::createFromYaml(sfConfig::get("sf_app_config_dir")."/menu.yml") ?>
<?php echo $menu->render() ?>
  • Display a menu programatically:
<?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() ?>