How do I add a parameter / option to a Joomla 2.5 component?

I want to add a setting in the administrator options for my component. And then I want to use that parameter on the frontend of the component. What's the code for parameters in components?

Category: Development 4 years ago
Asked 4 years ago

Go to your joomla/administrator/components/com_mycomponent/ and in your components backend folder find (or make) config.xml. This is where the parameters found in admin area of component by clicking the 'options' toobar menu item are coded in. This example creates a parameter for wether or not to integrate Jomsocial;

<fieldset name="Integrations"


              description="Utilize other components" >

        <field name="jomsocial" type="checkbox" value="1"

               label="Jomsocial:" description="Adds: JS User avatars and private messaging system." />



Then login as admin and set the option to desired value. Access the parameter on frontend with the following;

jimport('joomla.application.component.helper'); $params = JComponentHelper::getParams('com_mycomponent'); $jomsocial = $params->get('jomsocial');

Answered 4 years ago

Please register/login to answer this question.  Click here to login
Cron Job Starts