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.
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
Comment #1
JacineShould we start with list first? Should this be a meta issue, or do we want to do more at once?
Comment #2
effulgentsia CreditAttribution: effulgentsia commentedWe need to start somewhere. List seems like a great first choice, but I'm open to whatever.
Comment #3
effulgentsia CreditAttribution: effulgentsia commentedWhile 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.
Comment #4
bleen CreditAttribution: bleen commentedrelated: #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
Comment #5
steveoliver CreditAttribution: steveoliver commentedIn 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')
replacingtheme('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).Comment #6
podarokTagging
Comment #7
steveoliver CreditAttribution: steveoliver commentedI 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').
Comment #8
psynaptic CreditAttribution: psynaptic commentedI 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 dynamictag
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.
Comment #9
RobW CreditAttribution: RobW commentedKeep an eye on #1804488: [meta] Introduce a Theme Component Library too, to make sure we don't duplicate/invalidate work.
Comment #10
sunAlthough 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.
Comment #10.0
sunAdded link to Jacine's blog post.