[drupal-devel] Re: [drupal:dries] /includes theme.inc
drupal-devel-owner at drupal.org
drupal-devel-owner at drupal.org
Wed Oct 19 07:05:54 UTC 2005
Op 18-okt-2005, om 16:45 heeft drupal-devel at drupal.org het volgende
geschreven:
> User: dries Branch: HEAD Date: Tue, 18 Oct 2005 14:45:09 +0000
>
> Modified files:
> /includes theme.inc
>
> Log message:
> - Patch #32573 by Moshe: added support for ordered lists to
> theme_item_list().
>
> Links:
> http://cvs.drupal.org/diff.php?path=drupal/includes/
> theme.inc&old=1.261&new=1.262
>
> --
> [ Drupal cvs list | http://list.drupal.org/ ]
>
>
I do not, and I repeat _not_ like this approach!
A nicer solution would imo be:
/**
* Return a themed list of items.
*
* @param $items
* An array of items to be displayed in the list.
* @param $title
* The (optional) title of the list.
* @return
* A string containing the list output.
*/
function theme_item_list($items = array(), $title = NULL, $type =
'unordered list') {
$class = str_replace('-', ' ', $type);
if (isset($items)) {
switch($type) {
case 'unordered list':
$list .= '<ul>';
foreach ($items as $item) {
$list .= '<li>'. $item .'</li>';
}
$list .= '</ul>';
case 'ordered list':
$list .= '<ol>';
foreach ($items as $item) {
$list .= '<li>'. $item .'</li>';
}
$list .= '</ol>';
case 'definition list':
$list .= '<dl>';
foreach ($items as $item) {
$list .= '<dt>'. $item .'</dt>';
}
$list .= '</dl>';
}
if (isset($title)) {
$output .= '<h3>'. $title .'</h3>';
}
$output .= '<div class="'. $class .'">'. $list .'</div>';
return $output;
}
Isn't something like this nicer? And, easier to use?
Steef
---
Stefan Nagtegaal
Drupal-Devel at iStyledThis.nl
Drupal Development Mailinglist
More information about the drupal-devel
mailing list