Get User Info to Menu Last Record in ewmenu (Menu_Rendering)

Tips submitted by PHPMaker users
Post Reply
ASC
User
Posts: 1

Get User Info to Menu Last Record in ewmenu (Menu_Rendering)

Post by ASC »

Hi,
Refers to PHPMaker 11.0
Add this Function to Server events -> Global -> All Pages -> Menu_Renedering.
Change the Sql Query to whatever you want to show from your User Table. My Table is called employee in this sample and I select the Field Firstname to Show in the Menu. The User can click on this Menu Link and the Home page will loaded. You can add any other Page which you like or an hover function to show an image.

function Menu_Rendering(&$Menu) {
if ($Menu->IsRoot) { // Root menu
if (CurrentUserName() == "Administrator") {
$showname = "Scheiserle";
} else {
//$showname = ew_ExecuteScalar("SELECT CONCAT(FirstName, ' ', LastName) FROM employee WHERE UserLogin = '" . ew_AdjustSql(CurrentUserName()) . "'");
$showname = ew_ExecuteScalar("SELECT FirstName FROM employee WHERE UserLogin = '" . ew_AdjustSql(CurrentUserName()) . "'");
}
$Menu->AddMenuItem(10000, "mi_username", "Welcome: ".$showname, ".", -1, "", IsLoggedIn());
$Menu->MoveItem("mi_username", $Menu->Count() - 1); // Move to last
}
}

If you like to show different colors for the User permitted Menu's like Logout, Change Password etc. add following ID's to the Style Editor (after Beginn User Styles:
#mi_logout a,
#mmi_logout a,
#mi_changepwd a,
#mmi_changepwd a {
color: #265A88;
}
#mi_username a,
#mmi_username a {
color: #00CC66;
}
To make different colors for other Menu Items than use an additinal class.

.mas
{
color: #265A88;
}

Now you can change in the PHPMaker Menu Edtior your Menu items with <span class="mas">Your Menu Iteme Title</span>
This trick works for Captions too.

cheers
Alexander


cooleman
User
Posts: 4

Post by cooleman »

Thanks very much. it works very nicely
Care.


neo80
User
Posts: 6

Post by neo80 »

hello, as I get the menu shown above me around the user's full name?
I always appears at the end of the list and click Edit Menu not the title appears to me that to change the venue.
I hope you can help me. Thank you for your code


Post Reply