I have a simple Joomla plugin I wrote and added a field to the .xml manifest:

    <fields name="params">

        <fieldset name="basic">
                name="My plugin"
                label="My plugin"
                description="Format: example"



How does the value the Joomla administrator filled out in this field get passed to the myplugin.php?

From what I read it looks like params is a PHP object and then you parse it somehow? Also what is the data's name once it gets into the program? Does it use the label that's set in the .xml manifest?

2 Answers 2


Hot Tip:

the best way to find out how Joomla does things is to look at a core extension that's doing what you want. eg. look at the code for the plugin/user/joomla plugin.

In the manifest one config field is 'mail_to_user'

    class="btn-group btn-group-yesno"
    <option value="1">JYES</option>
    <option value="0">JNO</option>

And in the php it's retrieved like

class PlgUserJoomla extends JPlugin

// ... code here ...

    public function onUserAfterSave($user, $isnew, $success, $msg)
        $mail_to_user = $this->params->get('mail_to_user', 1);

    // etc

The first argument in the get method is the field's name. The second argument is the default value.

  • Thanks! I have a question. How is params working without it being $params? Nov 24, 2017 at 3:59
  • Are you asking why is it written "$this->params->get()" rather than "$this->$params->get()" or am I misunderstanding? Nov 24, 2017 at 7:50
  • @Edward_178118 - JPlugin automatically makes the basic properties of your plugin accessible, such as parameters ($this->params), so you can access them without having to pass the object through the function.
    – Lodder
    Nov 24, 2017 at 11:27

@Jamesgarret answered how we can access the parameters of the plugin that are set by the administrator.

To answer your other question:

Also what is the data's name once it gets into the program? Does it use the label that's set in the .xml manifest?

This is not the label - it is the name of the field you set in your plugin's xml. Label is the text that will be shown in the form left to your field.

It's also better if you could use some naming convention for the names you give to your fields. I have never seen anyone use words separated with spaces. It will still work though, but it doesn't look that good. Usually it's preferable to use underscores or camelCase convention, to separate words for the name of the field.

Finally, when you write a plugin, you should usually do it by extending the JPlugin class.

class plgSystemMyPlugin extends JPlugin

JPlugin Class is handling all of the basic properties for plugins, which will allow you to access them within your plugin's methods:

$this->params; //The parameters of the plugin as set in the admin:
$this->_name; //The name of the plugin
$this->_type; //The folder of the plugin.
$this->db; //The db object.
$this->app; //The application object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.