Request: House Ads Plugin

I thought of this request again, and it turns out that it’s fairly simple to implement without a plugin now by using Theme Components.

The code for placing an ad above topics, and after every 3 posts:

<script type="text/x-handlebars" data-template-name="/connectors/topic-above-post-stream/my-house-ads">
<div style="margin-bottom:10px;">
  <a href="http://www.discourse.org/buy">
    Discourse Hosting For YOU!
  </a>
</div>
</script>

<script type="text/discourse-plugin" version="0.8.23">
    api.decorateWidget('post:after', helper => {
        let post = helper.getModel();
        if (post.get('post_number') % 3 === 0) { // after every 3 posts
            return helper.rawHtml(`
<div style="margin-bottom:10px">
  <a href="http://www.discourse.org/buy">
    Discourse Hosting For YOU!
  </a>
</div>
            `);
        }
    });
</script>
14 Likes