Core has >200 theme functions and templates. Many contrib module adds a bunch more. So themers trying to take control of all markup have to hunt down and override a lot.

Meanwhile, do theme_item_list(), theme_task_list(), book-navigation.tpl.php, and a dozen or so other list generating functions/templates really need their own primary theme functions? Perhaps we can organize things better into generic primary theme hooks (e.g., 'list'), and use suggestions or other techniques for still being able to customize specific incarnations?

See also Jacine's blog post about this.

Comments

Jacine’s picture

Should we start with list first? Should this be a meta issue, or do we want to do more at once?

effulgentsia’s picture

Title: Reduce the number of theme functions/templates » [Meta] Reduce the number of theme functions/templates

We need to start somewhere. List seems like a great first choice, but I'm open to whatever.

effulgentsia’s picture

While I still think 'list' is a good one to get our feet wet with, we might also want to soon tackle the remaining ones from #1077510: Convert core templates and theme functions to HTML5 - Meta Issue, since the current difficulties with making some of those templates implement HTML5 correctly is one of the things we're hoping to solve by a more sane template organization structure.

bleen’s picture

related: #1190436-24: Full Pager: The ellipsis ("...") button does nothing gets rid of 4 theme functions (plus avoids adding a 5th) by using theme hook suggestions

steveoliver’s picture

In my quest to round up all the issues surrounding theme_item_list:

1. Tagging this issue with 'theme system cleanup' and 'Theme Component Library'.
2. +1 to theme('list') replacing theme('item_list') as it could logically be make to support definition lists as per #54898: Add a description-list.html.twig template (ex. definition list).

podarok’s picture

Issue tags: +Twig

Tagging

steveoliver’s picture

I just created #1813426: [meta] Consolidate all item list templates and add theme_hook_suggestions. I hope it helps centralize discussion about how far we want to consolidate around theme('item_list').

psynaptic’s picture

I love this initiative.

We should definitely use theme('list').

Anything that requires a different markup structure should use a theme suggestion. How about something like:

theme('list_unordered')
theme('list_ordered')
theme('list_definition')

Of course, unordered and ordered are so similar that they could just be the default for theme('list') and use a dynamic tag variable.

This could look on the face of it like we're adding more templates but I think the main issue is that we currently have so many theme functions for rendering lists that we really need to centralize all the list-rendering.

RobW’s picture

Keep an eye on #1804488: [meta] Introduce a Theme Component Library too, to make sure we don't duplicate/invalidate work.

sun’s picture

Status: Active » Closed (duplicate)

Although this one came first, I'm marking it as duplicate of #1804614: [meta] Consolidate theme functions and properly use theme suggestions in core, since that one is much more actionable and already started to outline issues related to the effort.

Please follow #1804614: [meta] Consolidate theme functions and properly use theme suggestions in core to work on this.

You may also follow #1804488: [meta] Introduce a Theme Component Library to discuss.

sun’s picture

Issue summary: View changes

Added link to Jacine's blog post.