How to use PHP code in menu counter component

This tutorial shows you how to show a number beside a menu item by using PHP Code. In our example we will show a number of products beside Product menu item.

menu counter example

For this tutorial, you have to login into developer panel of your application.

1. Navigate to Navigation menu item in developer panel.

2. Drag and drop Menu counter component from all components list to product menu item in navigation tree.

menu counter component

3. In dropped menu counter component properties, for Data source type property choose PHP Code.

4. Click on Data source PHP field and enter your PHP code. Variable result is an instance of AjaxProxy class. This variable is already instantiated. Attribute data of result variable ($result->data) must be a number or an array with data array key. Click on Save button.

5. Click on Save changes, go into your application and check out the results.