Adding a custom intro just for the homepage


(Charles Walter) #1

Anyone know how this community adds their custom intro? It appears only on the homepage.


(cpradio) #2

This seems to be the logic

    var __route = require('discourse/routes/discovery-categories').default;
    __route.reopen({
        activate: function() {
            this._super();
            Em.run.next(function(){
              $('.welcome-message').show();
              $('.circle-img-welcome').show();
              $('body').addClass("showing-welcome");
            });
        },
        deactivate: function() {
            this._super();
            $('.welcome-message').hide();
            $('.circle-img-welcome').hide();
            $('body').removeClass("showing-welcome");
        }
    });

(Charles Walter) #3

Cool. It works. Not sure what the purpose of the addClass or removeClass is for. Do we know who the author of this is?

I added this to the end of my ‘/head’ fragment:

<script>
var __route = require('discourse/routes/discovery-categories').default;
    __route.reopen({
        activate: function() {
            this._super();
            Em.run.next(function(){
              $('.welcome-message').show();
            });
        },
        deactivate: function() {
            this._super();
            $('.welcome-message').hide();
        }
    });
</script>

And then added a div with the class .welcome-message to my ‘header’ fragment.

Preview can be seen here:


#4

I tested the code with my installation, but it simply doesn’t seem to work:

I added a test123 div into top area
It shows up on every page


(Charles Walter) #5

Havent tried it in a while, as we switched backed to latest posts. Believe it was working when we had categories as our default page