2017 © Pedro PelĂĄez
 

fuel-package fuel-menu

Fuel wrapper around Knp Menu package

image

indigophp/fuel-menu

Fuel wrapper around Knp Menu package

  • Thursday, October 9, 2014
  • by mark.sagikazar
  • Repository
  • 0 Watchers
  • 0 Stars
  • 36 Installations
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Fuel Menu package

Menu package for FuelPHP framework., (*1)

Install

  • Through OIL: oil package install
  • Download package
  • Clone repo

Run migration: oil refine migrate --packages=menu, (*2)

Usage

build('main');

    //OR static way
    \Menu::build_static('main');
?>

Configuration

The default configuration:, (*3)

<?php
    protected static $_defaults = array(
        'menu' => "<ul>{menu}</ul>",
        'item' => "<li>{item}\n{submenu}</li>\n",
        'item_inner' => '<a href="{link}" title="{title}">{text}</a>',
    );
?>

When somthing is not found, this will be the fallback configuration., (*4)

If you want to use different configuration for submenus, you can define different configuration by adding 'sub_' prefix to the specific config item, like this:, (*5)

<?php
    protected static $_defaults = array(
        'menu' => "<ul>{menu}</ul>",
        'item' => "<li>{item}\n{submenu}</li>\n",
        'item_inner' => '<a href="{link}" title="{title}">{text}</a>',
        'sub_menu' => "<ul>{menu}</ul>",
        'sub_item' => "<li>{item}\n{submenu}</li>\n",
        'sub_item_inner' => '<a href="{link}" title="{title}">{text}</a>',
    );
?>

You can also modify the parent in case it has children, using this configuration:, (*6)

<?php
    protected static $_defaults = array(
        'menu' => "<ul>{menu}</ul>",
        'item' => "<li>{item}\n{submenu}</li>\n",
        'item_inner' => '<a href="{link}" title="{title}">{text}</a>',
        'item_sub' => "<li>{item}\n{submenu}</li>\n",
        'item_inner_sub' => '<a href="{link}" title="{title}">{text}</a>',
    );
?>

And if the parent is a submenu:, (*7)

<?php
    protected static $_defaults = array(
        'menu' => "<ul>{menu}</ul>",
        'item' => "<li>{item}\n{submenu}</li>\n",
        'item_inner' => '<a href="{link}" title="{title}">{text}</a>',
        'sub_item_sub' => "<li>{item}\n{submenu}</li>\n",
        'sub_item_inner_sub' => '<a href="{link}" title="{title}">{text}</a>',
    );
?>

Note: this will apply for every submenu which has children, when defined., (*8)

Last, but not least: You can define your own field for every menu item., (*9)

<?php
    protected static $_defaults = array(
        'menu' => "<ul>{menu}</ul>",
        'item' => "<li>{item}\n{submenu}</li>\n",
        'item_inner' => '<a class="{class}" href="{link}" title="{title}">{text}</a>',
    );
?>

A menu item MUST have a menu name, text, a parent, a position, optional: title, link Anything else is stored in an EAV container., (*10)

New menu(item)

 'main',
        'text' => 'This is a text',
        'title' => 'This is optional',
        'link' => '/to/somewhere'
    );

    $menu = \Model_Menu::forge($menu);
    $menu->attributes[] = \Model_Menu_Attribute::forge(array('key' => 'class', 'data' => 'myclass'));

    $menu->save();
?>

Future plans

I'm planning to add active menuitem option. I'm open to any ideas., (*11)

The Versions

09/10 2014

dev-develop

dev-develop https://indigophp.com

Fuel wrapper around Knp Menu package

  Sources   Download

MIT

The Requires

 

by MĂĄrk SĂĄgi-KazĂĄr

menu

30/01 2014

dev-master

9999999-dev https://indigophp.com

Fuel Menu package

  Sources   Download

MIT

The Requires

 

by MĂĄrk SĂĄgi-KazĂĄr

menu fuel