Problems adding custom button to discourse


(Bobby) #1

Hello all,
I have been trying to add a button in my menu on my site right here:

I have been putting this code in admin > customizations > CSS/HTML. It isn’t working in any section of CSS/HTML. I have tried them all. Anyway, here is the code I have been using:

    <script>
  Discourse.ExternalNavItem = Discourse.NavItem.extend({
    href : function() {
      return this.get('href');
    }.property('href')
  });

  I18n.translations.de.js.filters.google = { title: "Google", help: "Google" };

  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);
      list.push(Discourse.ExternalNavItem.create({href: 'http://www.google.com', name: 'google'}));
      return list;
    }
  });
</script>

Can somebody point me in the right direction?
Thanks.


(Jeff Atwood) #2

Why do you need a “Google” button there?


(Bobby) #3

I am using it as an example. I was actually going to use it for a button that leads to our donation store.


(Eric Vantillard) #4

You can create a plugin and use the plugin outlet header-before-notifications (see the header template)

see this tutorial about plugin outlets :

The babble plugins does exactly that see here


(Arpit Jalan) #5

We have a howto for this now: