Open Dreamwatcher opened 11 years ago
Thanks a lot!
Thanks for this man! I generated my menu array from the database, followed the tutorial step by step and the line
$this->MenuBuilder->setMenu('main-menu', $menus);
threw the error
Fatal error: Class 'MenuLib\Menu' not found in C:\xampp\htdocs\CakeProyect\app\Plugin\Menu\Controller\Component\MenuBuilderComponent.php on line 77
The only difference between the example menu array and mine is the property permissions
I'm using CakePHP 2.4
I will greatly appreciate any help!
It looks like you dont have the file "/app/Plugin/Menu/Lib/MenuLib/Menu.php". Please look for the path and correct your installation. Can you post a sample array?
First, thanks for your quick response.
I checked the existence of the file and the file exists.
This is the array I generated:
array (
array (
'title' => 'Usuarios',
'url' => array ( 'controller' => 'Usuarios', 'action' => 'index', ),
'permissions' => array ( 'admin', 'ejecutivo de cuentas', ),
'children' => array (
array (
'title' => 'Tipos de Usuario',
'url' => array ( 'controller' => 'TiposUsuarios', 'action' => 'index', ),
'permissions' => array ( 'admin', ),
'children' => array (
array (
'title' => 'Modulos',
'url' => array ( 'controller' => 'Modulos', 'action' => 'index', ),
'permissions' => array ( 'admin', ),
),
),
),
array (
'title' => 'Equipos',
'url' => array ( 'controller' => 'Equipos', 'action' => 'index', ),
'permissions' => array ( 'admin', ),
),
),
),
)
@giraam What version of PHP is running on your server?
This plugin would require at least PHP 5.3 I believe, in order to support the functionality of the class library and its namespaces.
@bmcclure I thought about the PHP version too since I have PHP 5.5 in my notebook so I tried with my office workstation where I use PHP 5.4 and I've had the exact same problem. I'll be honest, I have not delved much into the problem because I was in a hurry at the time but I'll be more than happy to test it again debugging the code. At first glance it should have worked.
Are you sure that you have put the following line in your Config/bootstrap.php file?
CakePlugin::load('Menu', array('bootstrap' => true));
If the plugin's bootstrap.php file isn't being loaded (via "'bootstrap' => true" above), these errors might result. That file registers an autoloader for the class library.
Even if you use CakePlugin::loadAll, you would still need to add an array key in there for Menu telling it to load it's bootstrap file.
@bmcclure not sure I did it. I will go back into my repository, test it again and I'll let you know.
@bmcclure indeed that was the problem!
"Even if you use CakePlugin::loadAll, you would still need to add an array key in there for Menu telling it to load it's bootstrap file."
I assumed wrong that CakePlugin::loadAll would do the trick. Thanks for your help and your time! It works as expected by adding that line.
The readme is too old to use them for installing this CakePHP-Menu. After hours of reading threads in the internet and reading the classes to install this Plugin correctly, i got it to work.
For beginners it is hard to understand what things are to do... Here a little tutorial:
So my components-array is now:
Use your new function in beforeFilter:
Ready! now your menu were built ;-)