Removing comment title from the display

Created on 3 February 2023, over 1 year ago
Updated 27 December 2023, 6 months ago

Comment subject (title) can be removed from the form display, but not from the display.
admin/structure/comment/manage/comment_forum/form-display

This causes that when a comment is added there is no subject, but the title is shown when the comment is viewed.

The title can be hidden from the forum using blocks, but it's not possible to hide title from the comments.

✨ Feature request
Status

Closed: works as designed

Version

11.0 🔥

Component
Olivero  →

Last updated about 7 hours ago

Created by

Live updates comments and jobs are added and updated live.
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.

  • Issue created by @mikko123
  • 🇮🇳India rksyravi New Delhi, 🇮🇳

    Hey @mikko123

    No option is available in Drupal Core to hide comment titles, but you can achieve this.

    1. Easy way: Rewrite comment.html.twig file and comment the below code.

    {% if title %}
            {{ title_prefix }}
            <h3{{ title_attributes }}>{{ title }}</h3>
            {{ title_suffix }}
          {% endif %}

    2. Write the customfieldFormatter file, write the logic as needed and update.

  • 🇮🇳India sidharth_soman Bangalore

    Here's a patch for the first method.
    I'm working on introducing a settings type config for this too. I'll update if I have any success.

  • Status changed to Closed: works as designed 6 months ago
  • 🇮🇳India Prashant.c Dharamshala

    @mikko123

    When you hide a field on the "Manage form display" page, it will be excluded from the create/edit forms of the corresponding entity. This action is not associated with "Manage display."

    The rendering of the field is contingent on the chosen field formatter, and users have the option to create their own field formatter.

    For those who wish to modify the output without creating a new formatter, the hook_preprocess_HOOK function can be utilized. More information can be found at: hook_preprocess_HOOK documentation

    For instance, if the HOOK is "comment," and "custom" represents the custom module's name:

    /**
     * Implements hook_preprocess_HOOK().
     */
    function custom_preprocess_comment(&$variables) {
      unset($variables["title"]);
    }
    
    

    This should address the current issue. If there are any concerns or if something has been overlooked, please feel free to reopen the issue.

    Thank you!

Production build 0.69.0 2024