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.
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:
Have fun with it.