Custom topic feed list


(bunjee) #1

Greetings discoursers,

Congratulations for the recent 1.1 release.

I’m trying to create a small topic feed list. It’s supposed to display a few filtered topics.

To get started, I took a look at basic-topic-list.js.es6.

Here is my js.handlebars:

<div class="w-feed-list">
{{#each topic in topics}}
    <a href="{{unbound topic.lastUnreadUrl}}">{{{unbound topic.fancy_title}}}</a>
{{/each}}
</div>

I’m not sure how to implement this on the controller.js side:

import DiscourseController from 'discourse/controllers/controller';

export default DiscourseController.extend(
{
    topics: // Retrieving a filtered topic list here
});

Anyone could give me a hand on how to do it ?

Thanks and Happy hacking :heart:.


(bunjee) #2

For the records, this is how I do it:

I create an ember component item-feed.js.es6 with the following:

export default Ember.Component.extend(
{    
    href: "latest",

    init: function()
    {
        this._super();

        var self = this;

        Discourse.TopicList.find(this.href).then(function(result)
        {
            self.set("topics", result.topics);
        });
    }
});

Afterward you create a handlebars template or populate render in item-feed.js.es6.

If you go for the render route just call self.rerender() after self.set("topics", result.topics).

P34C3.


(Pad Pors) #3

where is the render route? may someone help me understand this guide?