Request: House Ads Plugin


(Carlo) #1

I think it would be great if Discourse had plugin similar to Pockets from Vanilla Forums.

Just like Discourse AdPlugin, you can place ads on pre-determined locations.

The interesting thing is that you can insert any html ads every 3 or 4 post for example.

The good thing with jpg banners, is that you can “trick” adblockers by using random name ( eg, large image top, etc ).

Advertising Plugin for Discourse - Serve Ads on your Discourse Forum (Official Endorsed)
(Jeff Atwood) #2

That will only work if the images are coming from the same URL / domain as the rest of the “normal” images on the site.

I believe per @neil our official ad plugin can be configured to serve house ads as well, but those would be served from Google, etc, like the other ads.

(Neil Lalonde) #3

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="">
    Discourse Hosting For YOU!

<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="">
    Discourse Hosting For YOU!

(Joshua Kogan) #4

I copy/pasted the code into and it didn’t do anything. Any advice?

(Neil Lalonde) #5

Did you enable the theme? Or preview it?

(Joshua Kogan) #6

Thanks for the follow-up. I’m sorry for my late reply. I copy/pasted it into my current theme (with many theme components added) shown at, and I both previewed and enabled, but nothing. Then I created a new theme titled “house ads”, copy/pasted into the head, and enabled that theme – still didn’t work. Then, I went back to my original theme, and added the “house ads” component – still didn’t work. I may likely be doing something wrong here, and I appreciate any advice!

(Joshua Kogan) #7

Wait. Maybe it’s working as intended but, I was confused on how it should work… If I click on a topic, I see the “discourse hosting for you” link on the top of the topic/post page, but I thought it would also be woven into the latest list every three posts. Am I misunderstanding?

(Daniela) #8

The problem is that API v0.8.23 is not supported on Discourse 2.0.3.

You should update your Discourse site, or try to change the API version from 0.8.23 to a generic 0.8

(Joshua Kogan) #9

Oh brother, I’m with – I have no idea how to move forward with either suggestion. I’ll reach out them. Thank you!

(Daniela) #10

They run the stable version of Discourse.

Try simply to change this line of the script:

<script type="text/discourse-plugin" version="0.8.23">


<script type="text/discourse-plugin" version="0.8">

(Joshua Kogan) #11

That worked. Thank you!

Now, although it worked, it worked differently than I thought it would. I thought the ad post would show up every third post in the “latest” list. Rather, it places the ad every third post in a topic’s stream. Do you know of anyway to insert a house ad in the “latest” list? Just curious.