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 jhodgdon on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Introduced in version:
8.x
Issue links:
Description:
theme('item_list') (or the theme_item_list() function, as it is currently implemented) has a new feature: You can pass in variable 'empty' with a string or render array value, and if there are no list items, this value will be output. This is similar to the 'empty' variable in theme('table').
Example of using this from a render array:
$build['foo'] = array(
'#theme' => 'item_list',
// This is the list of items to output.
'#items' => $results,
// This can be a string or a render array.
'#empty' => array(
'#markup' => t('There were no results. Try a less restrictive filter'),
),
'#title' => t('Search Results'),
'#list_type' => 'ol',
);
Impacts:
Module developers
Themers