Hi guys,
so I would like to make avatars by posts just like here:
Here:
How can I do it?
The discussion is about adding avatars by posts in categories with featured topics. Sevosik is seeking a solution to display avatars next to posts, similar to what is shown in the provided images. awesomerobot responds by explaining that the template needs to be overridden, specifically the featured-topic.hbs template. They provide a code snippet that can be added to the </head> section in the admin > customize > themes area, which includes the #user-link section to add the avatars. The code needs to be styled with CSS. Sevosik expresses gratitude and excitement about the solution.
You need to override the template. Some more details on how to do that here: Developing Discourse Themes & Theme Components
It’s a little harder to find the right template to override here because that category page is a template made of other templates. The one to override is featured-topic.hbs
Try adding this code to </head> in admin > customize > themes — I’ve added the #user-link section which should add the avatars, you’ll need to add some CSS to style it as you’d like.
<script type='text/x-handlebars' data-template-name='components/featured-topic'>
{{#user-link user=topic.last_poster}}
{{avatar topic.last_poster imageSize="small"}}
{{/user-link}}
{{raw "topic-status" topic=topic}}
<a class='title' href="{{unbound topic.lastUnreadUrl}}">{{{unbound topic.fancyTitle}}}</a>
{{topic-post-badges newPosts=topic.totalUnread unseen=topic.unseen url=topic.lastUnreadUrl}}
{{#if latestTopicOnly}}
<div class='last-user-info'>
{{i18n 'categories.latest_by'}} <a href="{{{unbound topic.lastPosterUrl}}}">{{unbound topic.last_poster.username}}</a>
<a href="{{unbound topic.lastPostUrl}}">{{format-age topic.last_posted_at}}</a>
</div>
{{else}}
<a href="{{unbound topic.lastPostUrl}}" class="last-posted-at">{{format-age topic.last_posted_at}}</a>
{{/if}}
</script>
Thats so amazing! Thank you so much ![]()