Using fieldsets to separate plugin paramenters in Joomla 2.5

Joomla 2.5 has reached its end of life as for 12/31/2014. Please be advised this may be a security risk to your website. You can view more information about the end of life here.

When working with Joomla 2.5 plugins, you may have noticed that some of the parameters are divided into separate parameter types, such as Basic Options and Advanced Options. If you’re writing your own Joomla 2.5 plugin, you can do this separation by adding parameters to different fieldsets.

Fieldset Names

Here is our helloworld’s xml file thus far:

<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="content">
        <name>Hello World</name>
        <author>Brad Markle</author>
        <creationDate>June 18th, 2012</creationDate>
        <copyright>InMotion Hosting</copyright>
        <license>GNU General Public License</license>
        <authorEmail>bradm@inmotionhosting.com</authorEmail>
        <authorUrl>http://www.inmotionhosting.com</authorUrl>
        <version>1.0</version>
        <description>This is my very first plugin! Simple Hello World Plugin that prints "Hello World" at the beginning of every article.</description>
        <files>
                <filename plugin="helloworld">helloworld.php</filename>
                <filename>index.html</filename>
        </files>
        <config>
                <fields name="params">
                        <fieldset name="basic">
                                <field name="alt-text"  type="text" default="" label="Alternative Text" description="Besides Hello World, you can specify other text here to print to the screen instead." />
                        </fieldset>
                        <fieldset name="more">
                                <field name="color" type="radio" default="black" description="Which color should the message be displayed in?" label="Color">
                                        <option value="black">black</option>
                                        <option value="red">red</option>
                                        <option value="blue">blue</option>
                                </field>
                                <field name="font-size" type="list" default="12" description="What size font should the message use?" label="Font size">
                                        <option value="8">8px</option>
                                        <option value="12">12px</option>
                                        <option value="16">16px</option>
                                </field>
                        </fieldset>
                </fields>
        </config>
</extension>

As you can see in the code we have two fieldsets, one named basic and one named more. You can see in the screenshot below how this separates the parameters:

fieldset-names

Fieldset Language definitions

You may have noticed from the screenshot that even though we set the second fieldset with a name of “more”, it shows as COM_PLUGINS_more_FIELDSET_LABEL. This is because by default there are only a certain set of names that you can use for fieldsets. These names are defined in the following file:

administrator/language/en-GB/en-GB.com_plugins.ini

When looking at en-GB.com_plugins.ini, you can see the following fieldset names are defined:

COM_PLUGINS_ADVANCED_FIELDSET_LABEL=”Advanced Options
COM_PLUGINS_BASIC_FIELDSET_LABEL=”Basic Options

If you want to label either of your fieldsets as “Basic Options” or “Advanced Options”, you must set the fieldset name to either basic or advanced.

Leave a Reply