Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By steveoliver on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
theme_item_list()
now supports a type
attribute to be specified for child list items, allowing child lists to have a different type than their parent.
Previously, the parent type was inherited by all child lists, preventing, for example, an unordered list from being contained within an ordered list.
Now, if type
is set for a child list, it will be used.
If not, the parent type will be inherited.
Example
Code:
$title = "Item list with custom child types";
$type = 'ol';
$attributes = array();
$items = array(
'li 1',
'li 2',
array(
// This child defines it's custom type.
'type' => 'ul',
'data' => 'li 3',
'children' => array(
'li 3.1',
'li 3.2',
array(
'data' => 'li 3.3',
'children' => array(
'li 3.3.1',
'li 3.3.2',
'li 3.3.3',
),
),
),
),
array(
// This child inherits the parent type.
'data' => 'li 4',
'children' => array(
'li 4.1',
'li 4.2',
'li 4.3',
),
),
);
print theme('item_list', array(
'items' => $items,
'title' => $title,
'list_type' => $type,
'attributes' => $attributes,
));
Output:
Impacts:
Module developers
Themers