1.5 Template Project

The Joomla! Documentation Working Group is running a project to develop detailed reference and tutorial material on Joomla! 1.5 templates.  There is a project page on the documentation wiki where you can see the work in progress and help us by contributing your knowledge.

Who's Online

We have 8 guests online

Help Site License

The Joomla! Help Site content is copyright © 2005 - 2008 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution NonCommercial ShareAlike 2.5. Some parts of this website may be subject to other licenses.
Home arrow Developer Manual arrow 11. API Reference arrow mosHTML::treeSelectList

mosHTML::treeSelectList PDF Print E-mail

Last reviewed: Not reviewed
phpDocumentor

mosHTML::treeSelectList

Generates an HTML select list from a tree based query list.

Syntax

string treeSelectList ( array &$options, int $id, array $preload, string $tag_name,
                                             string $tag_attribs, string $key, string $text, mixed $selected )

$options
is an array of objects that have been returned by a database query or the mosHTML::makeOption method.  Each object in the array must contain id and parent properties.
$id
is the id of the current list item.
$preload
is an array of objects that will be used to preload the selection list.  The objects might have been returned by a database query or the mosHTML::makeOption method.  The array may be empty.
$tag_name
is the name attribute of the HTML <select> tag.
$tag_attribs
is a string containing any additional attributes that you want to assign to the HTML <select> tag.
$key
is the name of the class variable holding the option 'value'.  Should generally be 'value'
$text
is the name of the class variable holding the option 'text'.  Should generally be 'text'.
$selected
is either a string value for a single value select list or an array for a multiple value select list.

Examples

Example 1: a single value select list:

$query = "SELECT * FROM #__menu WHERE menutype='mainmenu' ORDER BY ordering";
$database->setQuery( $query );
$src_list = $database->loadObjectList();
$selected = array();
$selected[] = mosHTML::makeOption( '2' );
echo mosHTML::treeSelectList( &$src_list, 1, array(), 'cid',
                 'class="inputbox" size="1"', 'value', 'text', $selected );

which might produce:

<select name="cid" class="inputbox" size="1">
  <option value="33">Joomla License</option>
  <option value="2" selected="selected">News</option>
  <option value="48">.      <sup>L</sup> All that's fit to print</option>
 
  <option value="49">.      <sup>L</sup> Everything else</option>
  <option value="39">Blog</option>
  <option value="4">Links</option>
  <option value="3">Contact Us</option>
  <option value="27">Search</option>
</select>
 

which will render as:

Example 2: a multiple value select list:

$query = "SELECT * FROM #__menu WHERE menutype='mainmenu' ORDER BY ordering";
$database->setQuery( $query );
$src_list = $database->loadObjectList();
 
$preload = array();
$preload[] = mosHTML::makeOption( '0', 'Select one or more menu options' );
 
$selected = array();
$selected[] = mosHTML::makeOption( '2' );
$selected[] = mosHTML::makeOption( '4' );
echo mosHTML::treeSelectList( &$src_list, 1, $preload, 'cid',
        'class="inputbox" size="10" multiple="true"', 'value', 'text', $selected );

might produce:

<select name="cid" class="inputbox" size="10" multiple="true">
  <option value="0">Select one or more menu options</option>
  <option value="33">Joomla License</option>
  <option value="2" selected="selected">News</option>
  <option value="48">.      <sup>L</sup> All that's fit to print</option>
  <option value="49">.      <sup>L</sup> Everything else</option>
  <option value="39">Blog</option>
  <option value="4" selected="selected">Links</option>
  <option value="3">Contact Us</option>
  <option value="27">Search</option>
</select>
 

which will render as:


Please report any errors on this page to the Developer Documentation Forum.

Last Updated ( Wednesday, 28 September 2005 )
 
< Prev   Next >