Original posters within a category list

I’m using the Feverbee by @pfaffman template as a basis for my customisations, and I’ve come up against an issue that I can’t find a solution for after much searching of the forums. The following section in my example contains the latest 3 entries from a specific category:

However, I can’t seem to change the user images to be those of the original poster, rather than the latest. I don’t think that information is passed by the category json, and I’m stumped in trying to add it.

I need to make this change as the latest poster may have been a member of our support staff, rather than someone who needs help.

3 إعجابات

Right so you need to pull in the users… you can edit the topicListThree section to:

  ajax("/latest.json?order=posts&ascending=true").then (function(result){
                     topicListThree = [];
                    var usersThree = result.users;
                    result.topic_list.topics.slice(0,3).forEach(function(topic){
                        topic.posters.forEach(function(poster){
                            poster.user = $.grep(usersThree, function(e){ return e.id == poster.user_id; })[0];
                        });
                        topicListThree.push(Topic.create(topic));
                    });
                    component.set('topicListThree', topicListThree);
                });

and then in the template you can replace the {{topic.last_poster_username}} part of the img src with {{topic.posters.[0].user.username}}

8 إعجابات

Amazing, thanks @awesomerobot. I’d got 2/3 of the way there but needed the assistance to get over the line!

إعجاب واحد (1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.