Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
Followup from #2636074: forum-list.html.twig replies are double escaped.
template_preprocess_forums()
generates a lot of HTML, making it hard to override in a custom theme.
Proposed resolution
Rewrite the preprocess function to provide data to the templates. Allow the templates to generate HTML based on the provided data (eg:
Remaining tasks
TBD
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
larowlanSounds good to me
Comment #8
maestrojed CreditAttribution: maestrojed commentedData passed to template_preprocess_forums(&$variables) includes an item $variables['topics']. This is an array of topic objects.
One of the last lines of this function overwrites this $variables['topics'] item.
$variables['topics'] = $table;
While it was an array of topic objects and is being overwritten with a renderable table array. Data that is drastically different.
By doing this, any use of this hook will not have access to the original $variables['topics'] array. This makes the ability to preprocess topics heavely limited. You cannot loop through the topics and format them as you wish (like the forum modules does). It seems you are forced to accept the table markup.
Being that this function is a 'hook' and designed for data to be passed through as a reference, I would vote not to fundementally change the datatypes and general purpose of the data items passed in. Maybe, at least, save the original data format in a new item in the $variables array.
If there is a better direction for me to take to change that markup please let me know.
Comment #9
maestrojed CreditAttribution: maestrojed commentedMy previous comment was a duplicate of or at least better applies to:
https://www.drupal.org/project/drupal/issues/2890049
Comment #19
quietone CreditAttribution: quietone at PreviousNext commentedForum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.