Need help with theme template after_header.html

This would be one way to do it, you can add all of this to your header.html file. Essentially you need to make the data available for use in your template. Connector classes are explained a bit here.

<script type="text/discourse-plugin" version="0.8">
  const ajax = require('discourse/lib/ajax').ajax;
    api.registerConnectorClass('top-notices', 'custom-content', { 
        setupComponent(args, component) {
            $(function() {
              ajax("about.json").then (function(result){ // get about.json
                component.set('about-site', result.about); // set component with results of about.json
              });
          });
        }
    });
</script>

<script type="text/x-handlebars"   data-template-name="/connectors/top-notices/custom-content" >
   <p> {{about-site.description}} </p> <!-- Access description from about.json -->
</script>

This uses the plugin outlet called top-notices which is positioned similarly to after_header.html

There might be a simpler way, but this makes it easy to add a bunch of standard HTML in the template as well, and also makes it easy to pull in related content (anything that’s in about.json in this case)… for example {{about-site.title}}

10 Likes