How to add a new tab with content from a group?

Thanks :smile:

Disclaimer - I’m sure my solution is kinda hacky. There might be better solutions.

Basically, what I did was add some javascript to the page HEAD by adding a script under Admin > Customize > CSS, HTML > Header.

The script hooks into some of Discourse’s javascript events to manipulate the DOM and insert some html.
The advantage of this approach is that it can all be done through the admin panel so you don’t need to install plugins or fork the Discourse source code.

that said, here’s the source code:

<script>
Discourse.Route.reopen({
        activate: function() {
            this._super();
            Em.run.next(function(){
                insertIOITrackerConditionally();
            });
        } 
    });

function insertIOITrackerConditionally()
{
    if(jQuery("#ioi-tracker-li").length <= 0){
        jQuery('ul.nav :last').after('<li id="ioi-tracker-li" class="ember-view" title="track the activity of IOI employees on Hitmanforum"><a href="/groups/iointeractive">IOI Tracker</a></li>'); 
    }
//some other stuff here to format the page (if you're on the actual group page)    
    
}
</script>

the hack was inspired by https://talk.turtlerockstudios.com

Just insert it in the admin panel and you’re good to go.

Could you recategorize this thread under how-to? I’m sure others might have the same question.

4 Likes