Request: House Ads Plugin

AI-generated summary

The discussion revolves around implementing house ads in Discourse using Theme Components, inspired by the Pockets plugin from Vanilla Forums. Carlo requests a plugin similar to Pockets for placing HTML ads every few posts. codinghorror notes that the official AdPlugin can serve house ads but through external services. neil explains that house ads can be implemented without a plugin using Theme Components, providing code to insert ads above topics and every third post. Joshua_Kogan encounters issues, which dax attributes to an outdated API version; updating the script version resolves the issue. Joshua_Kogan confirms the fix but clarifies the ads appear in topic streams, not the ‘latest’ list, prompting a question about modifying the behavior. Carlo expresses interest in trying the solution.

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 ).

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.

1 « J'aime »

J’ai repensé à cette demande, et il s’avère qu’il est maintenant assez simple de l’implémenter sans plugin en utilisant les composants de thème.

Le code pour placer une publicité au-dessus des sujets et après chaque 3 messages :

<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">
    Hébergement Discourse pour VOUS !
  </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) { // après chaque 3 messages
            return helper.rawHtml(`
<div style="margin-bottom:10px">
  <a href="http://www.discourse.org/buy">
    Hébergement Discourse pour VOUS !
  </a>
</div>
            `);
        }
    });
</script>
14 « J'aime »

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

Did you enable the theme? Or preview it?

1 « J'aime »

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 www.sqrpgz.com, 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!

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?

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

2 « J'aime »

Oh là là, je suis avec Communiteq (anciennement DiscourseHosting).net — je ne sais pas comment avancer avec l’une ou l’autre des suggestions. Je vais les contacter. Merci !

Ils gèrent la version stable de Discourse.

Essayez simplement de modifier cette ligne du script :

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

par

<script type="text/discourse-plugin" version="0.8">
4 « J'aime »

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.

OMG, I can’t believe I missed your reply.

It sounds great! I’ll give it a try and let you know.

3 « J'aime »

Les publicités internes font désormais partie du plugin de publicité officiel.

Publicités internes dans le plugin de publicité officiel