This topic is locked

Changing the menu on all pages

12/11/2024 5:57:46 AM
PHPRunner Tips and Tricks
H
Henny Sol author

I had created two menus: main and Teachers.

In the ModifyMenu event I wanted to set the menu on all pages to main or to Teachers (based on some $_SESSION variables set in AfterSuccessfulLogin).

I couldn't find how to do it so I decided to have one complete menu (main) and to remove some items from the menu based on the variables:

if( $_SESSION["groupid"] == 2 and $_SESSION["IsTeacher"] == 1 ) {
for ($x = 28; $x <= 30; $x++) {
$menu->removeItem($x);
}

It works but I don't like it. Is there a way to set the menu for all pages to a different menu immediately after successful login?

Best regards ...