I love developing usable and rich web applications using the latest techniques available.

MenuHelper for CakePHP

November 4, 2008

It’s been a while since the last activity on my blog, but I want to get back posting again. Here’s my first attempt :)

I just released my MenuHelper for CakePHP. It’s a really simple class, but it saves time.
It allows you to generate menu’s and single links, if a link is currently active it adds an ‘active’ class.

Usage:
Copy menu.php to your helpers directory, and enable the helper by adding it to the $helpers array.

Then in your view you can do things like this:

// Echo a list with links
echo $menu->menu(array(
    array('Home', array('controller' => 'pages', 'action' => 'display', 'home')),
    array('Another link to home', '/', array('class' => 'another-link-to-home'))
), array('id' => 'my-menu'));

// Or a single link
echo $menu->link('Home', '/');

You can find the source on GitHub:

http://github.com/Pagebakers/menuhelper/tree/master/

Have fun with it.

Bookmark and Share
Filed under: Cakephp

5 Comments »

  1. hi Eelco, welcome back!

    what version of Cake is the helper for?

    04/11/2008 @ 7:02 pm — Luke
  2. Hey Luke,

    Should run on latest (RC3)

    04/11/2008 @ 10:11 pmEelco Wiersma
  3. [...] Wiersma сделал хелпер, помогающий создавать меню (пост про [...]

  4. Disculpa, los links que entregas no contienen el código que señalas, podrías revisar tus links.

    Saludos.

    25/03/2010 @ 4:53 am — entetangente
  5. excelente…había sido renombrado a NavigationHelper :P

    http://github.com/Pagebakers/navigationhelper/blob/master/navigation.php

    25/03/2010 @ 5:04 am — entetangente

Leave a comment