I Love PHPMaker

... because it gets even more powerful and flexible!!

  • About
  • Terms and Conditions
  • Membership Options
  • Sitemap
  • Downloads
    • PHPMaker Extensions Download
    • PHPMaker Projects Download
    • PHP Report Maker Extensions Download
I Love PHPMaker » Tips and Trick » How to Change Menu Item Text in Web Applications that Generated by PHPMaker 10.0.2
How to Display the Custom Message in Change Password Page When Password Has Expired in Web Applications that Generated by PHPMaker 10
A Case Study: Implementing Many-To-Many Relationship in Web Applications that Generated by PHPMaker 10

October 24, 2013

How to Change Menu Item Text in Web Applications that Generated by PHPMaker 10.0.2

Thank Goodness! A few minutes ago, I just found a nice trick how we can change the Menu Text on the fly easily and quickly by using the Menu_Rendering of Server Event in PHPMaker 10. In other words, let's say we want to change the Text that belongs to one of the Menu Items without having to either customize the generated code or customize the PHPMaker template files. Just for your information, this trick has not been documented in the Help file of PHPMaker. So I'm really sure you're gonna love it. 🙂

This following trick is very useful if you want to customize your Menu Text or Caption, for example, by adding the certain character or a small icon that precedes the Text of Menu Item. One of the use cases of this is, if you want to give a flag for the certain Menu Item that represents the active Theme for your web application. Yeah, just like a toggle flag for the Menu Item, so that user will know which theme that related to the Menu Item is currently active or selected by the logged in user.

But, in this trick below, we will not go too deep into that case. The example below will only give you the idea how we can change the certain Menu Text easily and quickly by using the powerful of Server Event in PHPMaker.

[hidepost]
Assume I have already a Menu Item which has the Text value of Blue. Then I want to change the Text by adding a "v" character before the Text Menu. Just for simplicity, I am using the "v" character. You may change it by using IMG tag in order to display a small icon that related to the "checked" character.

Okay, so here is the solution. Simply insert the following code into your Menu_Rendering server event:

	$Menu->FindItemByText("Blue")->Text = "v Blue";

Please note that if your web application uses Multi Language feature, then you have to handle the possibilities of the Menu Text in another language phrases. For example, my web application uses English and Indonesian languages, then that code above should be like the following:

	global $gsLanguage;
	if ($gsLanguage == "id") {  // check whether the Menu Text is in Indonesian
		$Menu->FindItemByText("Biru")->Text = "v Biru"; 
	} else { // assume default language always in English
		$Menu->FindItemByText("Blue")->Text = "v Blue";
	}

The alternative way to change the Text of Menu Item besides using FindItemByText() function as shown above, is by using FindItem() function; which has one parameter: The Menu ID.
For example:

$Menu->FindItem(1234)->Text = "New Menu Caption";

As we can see, the value of 1234 in that example above is the ID of the Menu Item. Don't forget to adjust it with yours.
[/hidepost]

Article by Masino Sinaga / Tips and Trick / menu, Menu_Rendering, PHPMaker 10.0.2, PHPMaker 10.0.3, PHPMaker 10.0.4, Server Events 2 Comments

How to Display the Custom Message in Change Password Page When Password Has Expired in Web Applications that Generated by PHPMaker 10
A Case Study: Implementing Many-To-Many Relationship in Web Applications that Generated by PHPMaker 10

Comments

  1. Anthony Percivalle says

    November 10, 2014 at 2:52 pm

    what about removing a single menu item. I am trying to accomplish removing certain menu items based on user level. Some of the items in the menu are links i created which i love but it should be integrated further I think.

    Log in to Reply
    • Masino Sinaga says

      November 10, 2014 at 3:00 pm

      To remove a single menu item, then you may simply use MenuItem_Adding server event, for example:

      if ($Item->Url == 'your-own-page.php') { // adjust your-own-page.php with yours!
        return FALSE;
      }
      
      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • A New PHPMaker 2020 Project File Is Released
  • PHPMaker 2020 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2020 Is Released!
  • Inventory Stock Management Project, Why Should You Have It?
  • A New PHPMaker 2019 Project File Is Released!
  • PHPMaker 2019 Demo Project File Is Released!
  • Masino Extensions for PHPMaker 2019 Is Released!
  • A New PHPMaker 2018 Project File Is Released!
  • PHPMaker 2018 Demo Project File Is Released!
  • Masino Extensions for PHPMaker 2018 Is Released!

Search

Recent Comments

  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!
  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!
  • Brien Devine on Masino Extensions for PHPMaker 2019 Is Released!
  • Brien Devine on Masino Extensions for PHPMaker 2019 Is Released!
  • Masino Sinaga on Masino Extensions for PHPMaker 2019 Is Released!

Demo Website

  • Demo of I Love PHPMaker 2020 (MasinoExtensions).
  • Indonesia Post Offices.
  • Stock Inventory Management.
  • Demo of PHPMaker + PHP Report Maker

Another Demo

The following template are not available in this site (must be purchased separately)

  • PHPMaker v2018 Horizontal Vertical Template.
  • PHPMaker v2017 Horizontal Vertical Template.

Demo Explanation

Stock Inventory Management is the good project for your reference, since it uses the real example in the real world. Many useful features you can use from this project, such as how to add the Thousand and Decimal separator character, and also how to calculate multiple row in Grid-Add when End-Users are entering data into the Grid-Add mode.

Categories

  • Customize Template (103)
  • General (3)
  • PHP Report Maker (17)
  • PHP Report Maker Extensions (2)
  • PHPMaker Extensions (76)
  • Tips and Trick (72)

Articles based on version

  • PHPMaker 2020
  • PHPMaker 2019
  • PHPMaker 2018
  • PHPMaker 2017.0.7
  • PHPMaker 12.0.7
  • PHPMaker 11.0.6
  • PHPMaker 10.0.5
  • PHPMaker 9.2.0
  • PHPMaker 8.0.3
  • PHP Report Maker 12

(c) I Love PHPMaker 2010 - 2019 by Masino Sinaga | WordPress | Log in | Back to top