public function onBeforeBuildVikAppointmentsMenu(MenuShape &$menu) : void

Fires before building the back-end main menu of the plugin.


Description

Plugins can use this hook to manipulate the back-end menu of VikAppointments at runtime.

It is useful in case you need to introduce additional separators and/or menu items. Otherwise, it is also possible to remove certain default menu items, such as the payments section.


Parameters

&$menu

(MenuShape)  The current menu instance. Since the argument is passed by reference, any changes applied to the instance will immediately take effect.

Return Value

None. Results are returned by modifying the referenced arguments.


Example

The example below adds the Mail Text menu item under the Global category, and removes the Countries menu item from Portal category.

/**
 * Trigger action to allow the plugins to manipulate the back-end menu of VikAppointments.
 *
 * @param   MenuShape  &$menu   The menu to build.
 *
 * @return  void
 */
public function onBeforeBuildVikAppointmentsMenu(&$menu)
{
    $input = JFactory::getApplication()->input;

    // get "Global" separator. It can be found at index [5]
    $global = $menu->get(5);

    // create "Mail Text" menu item
    $mailtext = MenuFactory::createItem(
       'Mail Text',
        'admin.php?page=vikappointments&view=mailtextcust', $input->get('view') == 'mailtextcust'
    );
    // set icon for mail text
    $mailtext->setCustom('envelope');
	
    // add item at the end of the list
    $global->addChild($mailtext);

    // get "Portal" separator. It can be found at index [3]
    $portal = $menu->get(3);

    // delete "Countries" menu item
    $portal->unsetChild(array(
        'title' => JText::_('VAPMENUCOUNTRIES'),
    ));
}

Changelog

VersionDescription
1.6.3 Introduced.
Last Update: 2021-10-05 16:28
Helpful?