How to Add Unique HTML Content Below Topic Body in discourse forum for Specific Topics

this.model contains the Topic data such as the id, title, etc. You can use that.

For example, to allow topic id 90 or 38, you would write:

<script type="text/x-handlebars" data-template-name="connectors/topic-area-bottom/custom-html">
  {{#if (or (eq this.model.id 90) (eq this.model.id 38))}}
    <div class="banner-control">
      <!-- Unique HTML content goes here -->
    </div>
  {{/if}}
</script>

However, I encourage you to use the Theme CLI and work with split files.

It will be difficult to add more conditions or have some logic there. It would be possible to use registerConnectorClass, but it’s deprecated.

The modern way is to use renderInOutlet with a glimmer component—for example, GitHub - discourse/discourse-custom-header-links.
You say you want to render in a specific outlet:

You have the template defined here. Notice the this.shouldShow

Then you can add your logic here to tell the component to be displayed or not:

I hope that helps. Let me know if you need additional assistance. :+1:

4 Likes