hide menu entry that is not generated automatically

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

hide menu entry that is not generated automatically

Post by nyukuri »

Hello,

Because I need to open a page with some additional parameters in the URL, I hid the table in the menu editor and added a menu entry manually specifying the path to the file with the parameters I need. That works fine.

The problem is, that not everybody has the right to see this table. But since the menu entry is made manually, the menu is always visible. So users click on the menu and then are told that they have no right to see that page. How can I hide this menu entry for the users who have no right to that page?

I am checking the $Item->Text in MenuItemAdding but need to check also if the currentuser has a right to that page...
How can I do that? I know of Security()->CanView but how to link this to the page that is to be opened by the menu entry?

Thank you very much for your help!

Nyukuri


mobhar
User
Posts: 11712

Post by mobhar »

You should keep using the original table that generated by PHPMaker in that Menu Editor. To change the URL, then you may simply use "MenuItem_Adding" server event, for example:

// Change the URL of "orders" table for current user level = 1 or 2
if ($Item->Url == "orderslist.php") {
if (CurrentUserLevel() == 1) {
$Item->Url = "myorderslist1.php";
} elseif (CurrentUserLevel() == 2) {
$Item->Url = "myorderslist2.php";
}
}


nyukuri
User
Posts: 123

Post by nyukuri »

Thank you, I had no idea that I have access to the URL attribute :)

How can I make that a menu entry link opens in a new tab/window (_blank) ? Is there a "target" attribute?


mobhar
User
Posts: 11712

Post by mobhar »

Yes, as well as "Url", $Item object also has "Target" property. Just try and enjoy! :-)


Post Reply