'dt', 'description' => 'dd') as $key => $tag) { $item = &$group[$key]; // If the item is a string, then there is only one DT/DD. if (is_string($item)) { $items[] = array( 'tag' => $tag, 'attributes' => array(), 'value' => $item, ); $item = array(array('#prefix' => "<$tag>", '#markup' => $item, '#suffix' => "$tag>")); } // Otherwise, there are multiple DTs/DDs. else { foreach ($item as &$value) { if (is_string($value)) { $items[] = array( 'tag' => $tag, 'attributes' => array(), 'value' => $value, ); $value = array('#prefix' => "<$tag>", '#markup' => $value, '#suffix' => "$tag>"); } else { $items[] = array( 'tag' => $tag, 'attributes' => isset($value['#wrapper_attributes']) ? $value['#wrapper_attributes'] : array(), 'value' => drupal_render($value), ); $value += array('#prefix' => '', '#suffix' => ''); $value['#prefix'] = "<$tag>" . $value['#prefix']; $value['#suffix'] = $value['#suffix'] . "$tag>"; } } } } } } /** * Returns HTML for a description list. * * @param array $variables * An associative array containing: * - items: The preprocessed list of description list elements to render. Each * item is an associative array containing: * - tag: Either 'dt' or 'dd'. * - attributes: An array of attributes to apply to the tag. * - value: The rendered content for the tag. * - groups: The original list of groups to render. Each item is an array * containing: * - term: One of the following values: * - A string containing the term. * - A list of of strings containing terms. * - A list of render arrays containing elements to render. Each child * element will be wrapped into a DT element. Use #wrapper_attributes * to specify attributes of the DT element. * - description: One of the following values: * - A string containing the description for the term. * - A list of of strings containing descriptions for the term. * - A list of render arrays containing elements to render. Each child * element will be wrapped into a DD element. Use #wrapper_attributes * to specify attributes of the DD element. * - title: (optional) A heading for the list. * - attributes: (optional) Attributes to apply to the DL element. * * @return string * The rendered description list. * * @ingroup themeable */ function theme_description_list($variables) { $items = $variables['items']; $output = ''; foreach ($items as $item) { $output .= '<' . $item['tag'] . drupal_attributes($item['attributes']) . '>'; // using drupal_attributes() instead of D8 new Attribute() $output .= $item['value']; $output .= '' . $item['tag'] . '>'; } // Only output the list, container, and title, if there are any groups. if ($output !== '') { $output = '