Can anyone help me with this home modification code?

If you want to remove the column by overriding a template, this is a good starting point:

https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648#overriding-discourse-templates-23

It explains how to override templates to remove a column.

Direct solution
  1. In your admin pane, go to Customize → Theme → your theme → Edit CSS/HTML

  2. In the Head tab, paste this code:

    <script type="text/x-handlebars" data-template-name="list/topic-list-item.hbr">
      
    </script>
    
  3. Between the <script> tags, paste the content of the original template:
    https://raw.githubusercontent.com/discourse/discourse/main/app/assets/javascripts/discourse/app/templates/list/topic-list-item.hbr

  4. Remove this part:

    <td class="num views {{topic.viewsHeat}} topic-list-data">
      {{raw-plugin-outlet name="topic-list-before-view-count"}}
      {{number topic.views numberKey="views_long"}}
    </td>
    
  5. Go to the CSS tab and insert this code:

    .topic-list-header th.views {
        display: none;
    }
    
  6. Don’t forget to save your changes.

Result:


CSS only solution (much shorter):

.topic-list {
    .views {
        display: none;
    }
}

I add that overriding a template requires more “monitoring” because Discourse templates code can change from one version to another and it will be necessary to change your override accordingly.

A CSS solution is more flexible.

4 Likes