Hey Guys,
In this blog we are going to see how to add a parameter to a Joomla
component's menu item. This parameter can be used while referring
view level in Joomla 2.5.x or 3.x.
Following are the steps to achieve this.
Step 1:
You have to specify parameter / option in your_layout.xml file
in your component.
Lets say, you have to add “pageLimit” parameter to default layout
of a view named 'products'. For menu item, you have to create add
default.xml for this layout and have to add parameter entry as
given below.
a. Add a xml file at location
site/components/com_yourcomponent/views/products/tmpl/default.xml
b. Add following code in above xml file
<?xml version="1.0" encoding="utf-8"?> <metadata> <layout title="All Products View" option="View" > <message><![CDATA[Quick2Cart All Products View]]></message> </layout> <!-- Add fields to the parameters object for the layout. --> <fields name="params"> <fieldset name="advanced" label="COM_MENUS_LAYOUT_FEATURED_OPTIONS"> <field name="pageLimit" type="text" default="20" label="Product Limit" description="Limit to display product on All products view" /> </fieldset> </fields> <state> <name>All Products</name> <description>All Products View </description> </state> </metadata>
After adding the file, this parameter will be displayed while creating menu item for products view. Refer the following screen-shot for this.
Step 2 :
How to get menu parameter or options to use in queries?
// Getting menu Param $menuParam = JFactory::getApplication()>getParams(); $pageLimit = $menuParam->get(pageLimit, 10);
Using above code you can get menu parameter / option and can use it accordingly.
I hope this will help you. If there are any questions, feel free to add a comment. :)