Replace links.html.twig with item-list--links.html.twig

Created on 20 September 2008, about 16 years ago
Updated 29 January 2023, almost 2 years ago

Problem/Motivation

We have two very similar templates in Drupal links.html.twig and item-list.html.twig. Both of these templates loop through a set of items, and create a HTML list. This creates twice as much code to maintain, and two separate, nearly identical, things to keep up to date.

Proposed resolution

Let's remove links.html.twig, add item-list--links.html.twig and call theme('item_list__links') to generate link lists. This implies adding the heading tag functionality to item-list.html.twig and converting the template to handle keyed item lists, and turning those keys like links.html.twig currently does

Remaining tasks

  1. #2032645: Replace calls to theme('item_list') with calls to theme('links') for links, when a heading or wrapper div is warranted
  2. 📌 Remove title and wrapper div from item-list.html.twig Needs work
  3. #939462: Specific preprocess functions for theme hook suggestions are not invoked
  4. Replace links.html.twig with theme('item_list__links') to generate the link list items throughout core (this issue)

User interface changes

None.

API changes

TBD

Related Issues

Postponed by: #939462: Specific preprocess functions for theme hook suggestions are not invoked
#1813426: [meta] Consolidate all item list templates and add theme_hook_suggestions
#1804614: [meta] Consolidate theme functions and properly use theme suggestions in core
#1939064: Convert theme_links() to Twig

Original report by @RobLoach

There's a function available to create an HTML list of items (theme_item_list), and there's a function to create an HTML list of links (theme_links). Wouldn't it make sense to make the function that creates a list of links take advantage of the function that creates the HTML list of items?

This patch makes theme_links use theme_item_list to create the list of links.

📌 Task
Status

Needs work

Version

10.1

Component
Theme 

Last updated about 15 hours ago

Created by

🇨🇦Canada RobLoach Earth

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024