SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 134 | Next

James Kennard

"Mastering Joomla! 1.5 Extension and Framework Development"


JHTMLSelect::option() returns an object that represents a list option.
JHTMLSelect::genericList() returns a rendered HTML string of a form select tag
based on an array of objects and a few additional parameters.
This example shows how we can implement the JElementMenus class:
/**
* Renders a Menus Selection List
*
*/
class JElementMenus extends JElement
{
/**
* Element type
*
* @access protected
* @var string
*/
var $_name = 'Menus';
/**
* Gets an HTML rendered string of the element
*
* @param string Name of the form element
* @param string Value
* @param JSimpleXMLElement XML node in which the element is
defined
* @param string Control set name, normally params
*/
function fetchElement($name, $value, &$node, $control_name)
{
// get the CSS Style from the XML node class attribute
$class = $node->attributes('class') ? 'class="'.$node->
attributes('class').'"' : 'class="inputbox"';
Component Design
[ 98 ]
// prepare an array for the options
$groups = array();
foreach ($node->children() as $group)
{
// create new Group, signifies a group
$text = $group->data();
$groups[] = JHTMLSelect::option('',
JText::_($text));
foreach ($group->children() as $option)
{
// add an option to the group
$val = $option->attributes('value');
$text = $option->data();
$groups[] = JHTMLSelect::option($val,
JText::_($text));
}
// end the group
$groups[] = JHTMLSelect::option('
');
}
// create the HTML list and return it (this sorts out the
// selected option for us)
return JHTMLSelect::genericList($groups,
''.


Pages:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146