Add External Menu in PHPMaker
PHPMaker Tutorial Series
Hi All, welcome to PHPMaker Tutorial Series.
Sometimes in developing website, we want to add external link as a menu in our website so called External menu. External menu in PHPMaker means we integrate our website with another link that once we click the link, it will open in new tab. We don’t need to leave our page just to open the external link. Since PHPMaker is unique, we can’t directly tell the menu target to be blank, so we need to configure it.
Here’s the tutorial to add external menu in PHPMaker.
1. Let’s open our project.
Our project file ends with .pmp and here’s my project file looks like
2. Add Menu
Click menu icon and Menu editor window will be pop out. Add Title of our new menu and paste our external url on url column as shown below.
3. Generate project
4. Find The Secret Number
Open root directory, find menu.php. This file can be find in folder <root folder>/view/.
Open menu.php in notepad or vscode, then find the ‘secret number’ of our new external menu.
in this case, 293 is my secret number of the external menu i already added before. Take a notes then back to our project
5. Configuring the Server Codes
Go to sever_codes and click menu rendering. Paste this code inside the bracket code of menu rendering.
function Menu_Rendering($menu)
{
// Change menu items here
$menu->FindItem(293)->Target = "_blank";
}
6. Generate The Project Again
and Try it out !
External Menu will be shown at sidebar.
As configured before, after we click the sidebar menu, browser will open new page without closing the current tab as shown below.