Basic parameter types in a Joomla 2.5 plugin

When adding parameters to Joomla 2.5 plugins, there are various input types you can use. In our testing thus far, we have only used the text input type. In this Joomla 2.5 tutorial, we’ll cover some of the various other plugin parameter types that you can use.

Basic parameter types in a Joomla 2.5 plugin

Radio type plugin parameters
Example Code:

<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>

The code to add a radio button as a plugin parameter is very similar to the standard code for using radio buttons in HTML.

Accessing the value of a radio button within your plugin’s php file is similar to getting the value of a standard text type field. As our field’s name above is color, we’ll get the value of the user’s color using that name, as in:


List type plugin parameters
A list parameter refers to a drop down list. In our hello world plugin, we added the following list to allow users to choose what font size they would like the message displayed using.
Example Code:

<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>

Again, accessing the parameter value itself is done in the same manner:


Text parameter input type
To make this a well rounded tutorial, we’ll also include the text input type (even though we referenced it in a previous article).
Example Code:

<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." />

To access this value, again use the following code in your plugin’s php file:


Leave a comment