Agile Toolkit has several menu implementations currently bundled.
Menu is also backwards compatible with Menu_Basic which was used before 4.3. The main reason for new menu was a more powerful HTML features for /css/menu.
Menu_Objective operates without templates and relies on Views for an elements.
I advise you to use Menu when in doubt and only look into other ones if you are super confident and you need a custom markup for your code.
It’s also possible that Menu_Basic will be removed from Agile Toolkit into an add-on in the next version.
It’s better if you use Menu_Vertical or Menu_horizontal directly. While both classes are mostly identical, the only thing different is a template.
This documentation will refer to the menus as Menu_Advanced.
Main Agile Toolkit Menu implementaiton.
You can call the following methods to populate the menu:
All of the above are quite similar as they both create a new View and return it. addSeparator does not take any arguments.
Other menthods accept first argument as a label text. This argument supports Component Definition Array format, enabling you to pass icon for instancee.
addItem() extends this format to also include icon2 (which will be placed) on the right and badge, which is also placed on the right (but can’t be used together with icon2). addMenu and addTitle does not support icon or badge, but you can still use icon.
addItem can have second argument - page. This argument can also be a hash (see URL array hash).
addMenu second arguent can be either ‘Vertical’ or ‘Horizontal’ and defaults to Horizontal.
Next is an example:
$this->menu = $this->add('Menu_Vertical'); $this->menu->addItem(['Dashboard', 'icon'=>'gauge'], 'index'); $m=$this->menu->addMenu(['Customers', 'icon'=>'smile']); $m->addItem(['Users', 'icon'=>'users'], 'users'); $m->addItem(['Purchases', 'icon'=>'money'], 'purchases'); $m->addItem(['Subscribers', 'icon'=>'chart-line'], 'subscribers'); $m->addItem(['Plans', 'icon'=>'basket'], 'plans'); $m=$this->menu->addMenu(['Installation', 'icon'=>'network']); $m->addItem('ATK Installs', 'installations');
Associate Menu with Model
Menu object supports use of Model. It will then iterate throug model data set and initialize menu items. More importantly - Menu support Hierarchy Models and will automatically create sub-menus as necessary.
The model must have the following fields: