CakePHP 3 create dynamic Menu


#1

I want load dynamic menu like categories->subcategories->items please help me how to create using element in cakephp 3.0


#2

contact me i can help you…


#3

Are there any answers to this question. I have it as well. I would assume that a RAD environment would have a SQL based menu striation as well.


#4

Well,

element are just parts of your view. So if you have a index.ctp with

<?= $this->element('menu') ?>

Cakephp expect you to have a file at app/src/Template/Element/menu.ctp

That one can have menu information (html as we are on views, right?)

About the menu itself:

You can have the information on database where you can get only the links your user have permission, but the final result can be a simple

< ul>
< li> item < /li>
< li> categories
< ul>
< li> subcategories
< ul>
< li>items< /li>
< /ul>
< /li>
< /ul>
< /li>
< /ul>

  • item
  • categories
    • subcategories
      • items

You can add some javascript and have a beautiful menu .


#5

Well that looks like code. A templated system should have a menu system that has a method of storing menu objects, in tables, that can be grouped into menus, sub-menus, as a the most basic function.

More complex menus would have roles, role based, menus and custom menus.


#6

you can use element do display and tree behavior to store menus in database
https://book.cakephp.org/3.0/en/orm/behaviors/tree.html