Skip to main content
Closed for Voting

How to change the topic_list template?

Related products:Freshdesk
  • March 30, 2020
  • 1 reply
  • 15 views

Hello.


I need to change the topic_list part of the page, which lists for the desired number of topics the forum name, the "Posted by" and the "Last Reply" information. I want to include in this template the "first post body (not HTML)", so the template could be shown the following way:


Name of the topic

First post body

Posted by <author>, 7 days ago

Last Reply by <commenter>, 7 days ago


The only difference now is that I don't have the "First post body" line. If I had access to the first post it probably would be the {{ topic.first_post.body }} of each post like described in the liquid placeholders page. This is a topic list template, which is different from my "Topic list" page that is listed in the side panel of my Portal Pages (see the attached image).


Thank you.

image_47022.png

1 reply

dineshs
Contributor
Forum|alt.badge.img+3
  • Contributor
  • March 1, 2022

Hi Rafael,

 

Instead of {{ forum | topic_list:5 }} you can use the below code.

{% for topic in forum.topics %}
    <div>
         {{  topic.first_post.body_html | truncate:160 }}
         <p>Posted by {{topic.user.name}}, {{topic.created_on | time_ago }}</p>
         <p>Last Reply by {{topic.last_post.user.name}}, {{topic.last_post.created_on | time_ago }}</p>

    </div>
 {% endfor %}

 

Regards,

Dinesh S