hey, looks cool – nice you included the manual option…I always end up doign this whenever I try and do a dyanmic menu, and it used to begin with an extra if else, then a case then … serenity etc :)

Luke on 9/15/08

it’s very usefull component, but for me it’s lack of some features. I wrote some mods for ex. possibility to set up custom controller’s title by setting $menuOptions[‘ctrlTitle’], because generic just takes ctrl’s name. I think it also needs automagic support for acl public functions to avoid warning if there is no aco’s for them while they are in allowedActions.

Natan on 10/28/08

When it comes about comment from your code “no active session, no menu can be generated”, i think support for for “no session menu” would be not bad, like i said last time we can check up just Auth’s allowedActions and generate menu for public functions.

Natan on 10/28/08

Natan: If check the gitHub, I’ve been working on improvements to the component as I come across the need for them. If you’ve added features or fixed things and would like to share send me an email through my contact form, or fork the code on gitHub, and make a pull request.

mark story on 10/29/08

Hei! I find this component very useful and promising! Good job! As a suggestion I would suggest to add someway to order the result of array, don’t know what ways would be the best, supose each item would need to have order number ( spacing of 10 ) and then it would be possible to manually tell menu->item(value, ordre). Creating database table would allow more possibilities for creating interface and adding translations more easily.

Tomppa on 1/7/09

Tomppa: If you check out a recent version from Github you’ll see that I’ve added a ‘‘weight” to the menu items. This allows manually added elements to be weighted. There is no ability to set weights for auto-generated menu items though. Perhaps I can add that in the future.

mark story on 1/8/09

Many thanks for the ACL code and the Menu Component. I have a couple of queries regarding the menu component.
1.The load cache routine doesn’t return the current users cache, but does return an empty array therefore successfully enters the if statement. As the writeCache sets the cachekey as User?_menu_storage, shouldn’t load cache also look for this?
2.A minor point I dont use the standard admin_index for the admin pages, as the generateRawMenu, sets $cakeAdmin = Configure::read(‘Routing.admin’), see line 300, I have replaced ‘admin_index’ with $cakeAdmin.’index’. These also appear on Line 87 & 360. This confused me for a while, as I searched for any references to admin? in my controllers.

Jonathan Jones on 1/26/09

Jonathan Jones: Thanks for pointing out those hardcoded values. I’ve updated them now.

mark story on 1/27/09

This component is really good. I’m just a n00b with Cake so I might be wrong but I think MenuComponent doesn’t support automagic when component’s name contains underscope (ex. good_pies). Is that hard to code ?

OstReach on 2/25/09

I deleted “if ($this->Acl->check($aro, $aco))” in constructMenu() and it kinda works for me.

OstReach on 2/26/09

Deleting the Acl->check() basically neuters the Acl controlled aspect of the menu. Which was the primary feature of this menu component. As for supporting underscores, its not hard, but wasn’t part of the original design that I built the component for. Controller names in CakePHP by convention don’t have underscores in them, so its not really necessary.

mark story on 2/26/09

Remove $aco = Inflector::underscore($item[‘url’][‘controller’]);

$aco = $item[‘url’][‘controller’];

instead to use controller names with underscopes

OstReach on 2/26/09

Great Component. One thing I noticed that if I don’t have an index action set up for a controller, it does not render the actions for that controller at all.
Is it me or any one else noticed this too ? – Anyhow, I’d post a fix here I get about doing it as for now I’m just adding / index action in ACOs and assigning permissions.

SayB on 3/24/09

To add weight to your menu:

1. Add the following code after the “$ctrlHuman = …” line inside the generateRawMenus function:

if (empty($menuOptions[‘weight’]) || !isset($menuOptions[‘weight’]) || !is_numeric($menuOptions[‘weight’])) { $ctrlWeight = 999;
} else { $ctrlWeight = $menuOptions[‘weight’];

2. Replace the line “‘weight’ => 0” with “‘weight’ => $ctrlWeight” in the generateRawMenus function

Now you can add the weight option inside the $menuOptions

Riaan on 7/1/09

Riaan: You could always fork the code on github and apply the patch too :)

mark story on 7/1/09

when cache in out of date i get this warning (debug set at 2):

Warning (512): DbAcl::check() – Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
( [User] => Array ( [id] => 1 [username] => pollution [group_id] => 1 [active] => 1 [created] => 0000-00-00 00:00:00 [modified] => 2009-09-09 11:30:47 )


Aco: controllers/pages/display [CORE/cake/libs/controller/components/acl.php, line 239]

same thing for all the other action out aco table

With updated cache all works!

congratulations for this blog … the best place to improve my cake skills!

pollution on 9/16/09

When I loaded this I had an error on line 201 with $aro[key($aro)][‘id’]. My user table’s primaryKey is user_id, so I updated it to match.

Now I load the page correctly, but I don’t see any menu. I’m not sure what I’m missing.

Ryan on 9/29/09

Obviously (now) I was missing that the menu options are now stored in the view array.

Has anyone written a helper to display the menu?

Ryan on 9/29/09

I like the idea and got it to work. However my ACOS table contains records with controller and action names. Should I just query the ACOS table instead to generate raw menus?

Doctor Who on 10/6/09

I can’t get it to work. Could you explain using the example of “Acl and Auth controlled app” from previous posts where and how create Menu and how display it?

noob on 10/16/09