Menu settings by server event (v11)

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

Menu settings by server event (v11)

Post by ppp »

Hello,
how could I set the menu "group title" and "URL" by server event? Is it possible?
I need it beacause I have to have different settings for different user levels


Webmaster
User
Posts: 9427

Post by Webmaster »

You can use MenuItem_Adding server event to set the the $item's IsHeader and Url properties. (v2020)


ppp
User
Posts: 41

Post by ppp »

thank you, I tryed this but it doesn't work, is there something wrong?

Assume that "MyItem" is set as “Group Title” in the Menu settings, so by default it’s not a link (user level 1), but with the other user levels I expect it become a link (but it doesn’t yet)

if (CurrentUserLevel() <> 1 && $Item->Text == “MyItem”) {

$Item->IsHeader = false;

if (CurrentUserLevel() == 2 || CurrentUserLevel() == 3) {
	$Item->Url = "page1.php";
}

if (CurrentUserLevel() == 4 || CurrentUserLevel() == 5) {
	$Item->Url = " page2.php";
}

if (CurrentUserLevel() == 6) {
	$Item->Url = "page3.php";
}

}


arbei
User
Posts: 9404

Post by arbei »

If v2020, the empty event is like:

function MenuItem_Adding($item) {
//var_dump($item);
// Return FALSE if menu item not allowed
return TRUE;
}

Make sure you use $item, not $Item. (PHP variable name is case-sensitive.)


ppp
User
Posts: 41

Post by ppp »

in phpm 11 is MenuItem_Adding(&$Item).
The "return true" is there..


mobhar
User
Posts: 11744

Post by mobhar »

PHPMaker v11 is too old to be discussed in here and will not be supported anymore. It had been phased out. So please always try the latest version, as of today is v2020.


Post Reply