[drupal-devel] Re: [drupal:dries] /includes theme.inc

Moshe Weitzman weitzman at tejasa.com
Wed Oct 19 14:08:05 UTC 2005


Calm down Steef ... Perhaps you want to submit a patch.

> 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?




More information about the drupal-devel mailing list