Move menu item

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
andyrav
User
Posts: 641

Move menu item

Post by andyrav »

Hi
Is it possible if so how to move a menu item if userlevel =1 to another child item menu
guessing from within Menu_Rendering

if ($menu->Id == "menu" && CurrentUserLevel() == 1) ) {


}

this item
$sideMenu->addMenuItem(10939, "mi_api_request_users", $Language->menuPhrase("10939", "MenuText"), "apirequestuserslist", 7385, "", AllowListMenu('{34716182-7E34-4865-8EFC-58352F3DEE70}api_request_users'), false, false, "", "", false, true);
into this menu
$sideMenu->addMenuItem(181, "mci_Utilities", $Language->menuPhrase("181", "MenuText"), "", -1, "", true, false, true, "fa-cloud", "", false, true);
thanks


arbei
User
Posts: 9384

Post by arbei »

Note that:

    public function addMenuItem(
        $id,
        $name,
        $text,
        $url,
        $parentId = -1,
        $src = "",
        $allowed = true,
        $isHeader = false,
        $isCustomUrl = false,
        $icon = "",
        $label = "",
        $isNavbarItem = false,
        $isSidebarItem = false
    )

The 5th argument is the parent menu ID, so in Menu_Rendering you may use findItem() to find the menu item you want to change by its id, then set its ParentId property.


andyrav
User
Posts: 641

Post by andyrav »

so
$this->FindItem(5)
returned the object menuitem
is there a way to find the item by name and not id number?
tried this but does not work
viewtopic.php?p=135988&hilit=FindItem#p135988

thanks


arbei
User
Posts: 9384

Post by arbei »

There is also findItemByText() method, see the source of the Menu class in src/Menu.php.


Post Reply