GithubHelp home page GithubHelp logo

weaverryan / iomenuplugin Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 16.0 286 KB

A plugin to make arbitrarily large menus easier to write.

Home Page: http://www.symfony-project.org/plugins/ioMenuPlugin

License: MIT License

PHP 100.00%

iomenuplugin's Introduction

ioMenuPlugin

A plugin to make menus easier to write in symfony.

  • Current menu item automatically given active class
  • Menu items automatically given first and last classes
  • Show/hide menus based on authentication, credentials
  • Hide portions of the tree, or render down to a certain depth
  • Menu rendered with "pretty" spacing for easier debugging & styling

Inspired by sympal and the SemanticMenu from Ruby on Rails.

A small book has been written to support this plugin and ioDoctrineMenuItemPlugin: Menu Reference Manual.

Usage

Assume any of the routes have been defined in routing.yml:

$menu = new ioMenu();
$menu->addChild('overview', '@homepage');
$menu->addChild('comments', '@comments');
echo $menu->render();

Assuming you are on /comments, the output would be:

<ul class="menu">
  <li class="first">
    <a href="/">overview</a>
  </li>
  <li class="current last">
    <a href="/comments">comments</a>
  </li>
</ul>

The ioMenu class optionally takes an array of attributes as its first argument. You can also nest menus as deeply as you want:

$menu = new ioMenu(array('class' => 'top_level_nav'));
$menu->addChild('overview', '@homepage');
$menu->addChild('comments', '@comments', array('class' => 'button'));

$menu['comments']->addChild('My Comments', '@my_comments');
$menu['comments']->addChild('Recent', '@recent_comments');

echo $menu->render();

Assuming you're in the /my-comments page, the output would be:

<ul class="top_level_nav">
  <li class="first">
    <a href="/">overview</a>
  </li>
  <li class="button current_ancestor last">
    <a href="/comments">comments</a>
    <ul class="menu_level_1">
      <li class="current first">
        <a href="/my-comments">My Comments</a>
      </li>
      <li class="last">
        <a href="/recent">Recent</a>
      </li>
    </ul>
  </li>
</ul>

Installation

With git

git submodule add git://github.com/weaverryan/ioMenuPlugin.git plugins/ioMenuPlugin
git submodule init
git submodule update

With subversion

svn propedit svn:externals plugins

In the editor that's displayed, add the following entry and then save

ioMenuPlugin https://svn.github.com/weaverryan/ioMenuPlugin.git

Finally, update:

svn up

Setup

In your config/ProjectConfiguration.class.php file, make sure you have the plugin enabled.

$this->enablePlugins('ioMenuPlugin');

In-depth documentation

An in-depth reference manual is available: Menu Reference Manual.

Care to Contribute?

Please clone and improve this plugin! This plugin is by the community and for the community and I hope it can be final solution for handling menus.

If you have any ideas, notice any bugs, or have any ideas, you can reach me at ryan [at] thatsquality.com.

A bug tracker is available at http://redmine.sympalphp.org/projects/io-menu

This plugin was taken from sympal CMF and was developed by both Ryan Weaver and Jon Wage.

iomenuplugin's People

Contributors

michalgor avatar weaverryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

iomenuplugin's Issues

url options doesn't work when using to / fromArray functions

I tried to configure my menu using app.yml and fromArray() method, but the option "url_options" is not exported. The same occurs when I use ->setUrlOptions() from PHP and toArray() function.

I checked the to and fromArray functions and I found that the code for this attribute is missing

Can you fix it, please?

Regards

Make it possible to set ulClass

I think it was very nice if we can set the ulClass of each item.

like this:
$menu->addChild('Homepage', '@homepage');
$menu['Homepage']->ulClass('subnav')->addChild('About Us', '@about_us');
$menu['Homepage']->addChild('other_link', '#');
$menu->addChild('Blog', '@blog');
$menu['Homepage']->ulClass('blog_subnav')->addChild('Archive', '@blog_archive');
$menu['Homepage']->addChild('other_link', '#');

isCurrent method is buggy with https

Hi :)

I have my domain in https and since i put the ssl, the isCurrent method of ioMenuItem seems buggy.

In the code you have

$url = $this->getCurrentUri();
$menuUrl = $this->getUri(array('absolute' => true));

In my context :

$menuUrl = "http://domain.com/ad"
and $url = "http://domain.com:443/ad"

When the isCurrent method do the comparison, $menuUrl and $url are not equal.

Do you have an idea how to fix that ? :)

Thanks a lot !

doc, chapter 1

162      $menu = new ioMenuItem(array('id' => 'root_menu');
163     $menu->addChild('overview', '@homepage');
164     $menu->addChild('comments', '@comments');

should be

162      $menu = new ioMenu(array('id' => 'root_menu');
163     $menu->addChild('overview', '@homepage');
164     $menu->addChild('comments', '@comments');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.