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.

 

Radio type plugin parameters

setting-up-a-radio-parameter

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

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:

$this->params->get('color')

 

List type plugin parameters

adding-a-list-plugin

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

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

$this->params->get('font-size')

 

Text parameter input type

standard-text-type-input

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:

$this->params->get('alt-text')

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Like this Article?

Comments

Post a comment
n/a Points
2014-06-25 5:06 am

Sir, 

Please tell how to update the php file with this code of  the radio type parameters and list type parameters.

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!