Just like some other theme_* functions, it would be handy if theme_item_list had a $attributes parameter.

As this is a fairly low-level themeable function, it tends to be used by higher-level functions in custom themes, and this would allow custom themes to rely on it while adding the ability to customize list display by passing attributes to be applied on the chosen list.

An incorrect workaround I've seen applied is to pass a third parameter like ul class="someclass", but this causes the function to generate incorrect HTML because the attribute string is carried into the element closure where it doesn't belong.

I'm therefore suggesting a patch for this feature. Discussion on IRC seems to suggest that, if this is agreeable to core maintainers, it might be useful to generalize this $attributes parameter to a larger number of theme functions.

CommentFileSizeAuthor
theme.inc_6.patch1.11 KBfgm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drumm’s picture

Title: theme_item_list should receive an attributed parameter » theme_item_list should receive an attributes parameter
Status: Needs review » Fixed

Still doesn't allow attributes on <li> tags, but better than nothing. I added a '.' at the end of the added documentation.

Committed to HEAD.

fgm’s picture

I thought about it, and thought it was generic enough: the attribute for the list element can be a class or id, which allow for styling the list-item elements by including the class/id in a selector.

Anonymous’s picture

Status: Fixed » Closed (fixed)