Welcome to the new HowToJoomla!

We've completely revamped the design to make the site easier to read and easier to navigate. We hope you like the changes!

How To Find Available Attributes for Parameter Elements

November 04, 2009 | by James Hafner | 0 Comments

This how-to is aimed more at Joomla! developers than our beginner or intermediate Joomla! user crowd. When creating an extension (module, component, plugin, or template), it's often necessary to give users the ability to choose custom settings by giving them Parameter options. Interacting with parameters will be for another How-To, but today I want to show you how to find the available attributes for a particular parameter element.

Parameter Elements

You're probably aware of the different parameter elements available to you, but just in case you're not, here they are:

  • calendar
  • category
  • editors
  • filelist
  • folderlist
  • helpsites
  • hidden
  • imagelist
  • languages
  • list
  • menu
  • menuitem
  • password
  • radio
  • section
  • spacer
  • sql
  • text
  • textarea
  • timezones
  • usergroup

So, when you're using one of these in a new extension, or you're modifying an extension, how do you know what attributes Joomla! will be looking for beyond the default attributes (name, type, default, label, and description)? With a little digging, it's pretty easy to determine.

Go Digging

Using your favorite FTP client or file explorer of choice, open up the files of your Joomla! installation. Navigate all the way to the following folder:

/libraries/html/parameter/elementml

Inside that /elements folder, you'll see a PHP file for each of our parameter elements. Open up calendar.php and look for the first (and only) function in the file. You should see something like this:

function fetchElement($name, $value, &$node, $control_name)
{
JHTML::_('behavior.calendar'); //load the calendar behavior

$format = ( $node->attributes('format') ? $node->attributes('format') : '%Y-%m-%d' );
$class = $node->attributes('class') ? $node->attributes('class') : 'inputbox';

$id = $control_name.$name;
$name = $control_name.'['.$name.']';

return JHTML::_('calendar', $value, $name, $id, $format, array('class' => $class));
}

The secret here is to look for the variables with a node. The calendar parameter type has two attributes: format, and class. Some parameters have more, some have less, each depending on what they're intended to do. However, exploring other parameter elements uncovers a few hidden secrets not seen in many extensions. For example, the folderlist parameter has the attributes "hide_none" and "hide_default", which hide the "None" and "Default" options from the folder list respectively.

About the Author

James Hafner

James Hafner is an Austin, TX-based developer who brings years of web experience to the HTJ team. He's worked with hundreds of companies large and small to develop their online presence, and has followed the Joomla! community since the Mambo days. He currently works as Senior Developer for Cory Webb Media, LLC. While leaving the really nerdy stuff to the other HTJ writers, James has a knack for finding things that make everyday life easier.  To him, developing, like Joomla!, is all about working smarter; not harder. You can follow James on Twitter @jhafner or check out his web site at JamesHafner.com.

Read More

Trackback(0)

Comments (0)Add Comment


Write comment

You must be logged in to post a comment. Please register if you do not have an account yet.

busy