Custom nav items no longer showing after recent update

I use this code (in the /head tab of the edit CSS/HTML customisation page) to add some additional items to the menu, however it’s stopped working after a recent update - anybody know why?

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

    I18n.translations.en.js.filters.first_name_here = { title: "Name", help: "Name again" };
    I18n.translations.en.js.filters.second_name_here = { title: "Name", help: "Visit our...." };
    I18n.translations.en.js.filters.tags = { title: "Tags", help: "Tags" };

    Discourse.NavItem.reopenClass({
      buildList : function(category, args) {
        var list = this._super(category, args);
        if(!category) {
          list.push(Discourse.ExternalNavItem.create({href: 'http://forum.com/tags', name: 'tags'}));
          list.push(Discourse.ExternalNavItem.create({href: 'https://forum.com/something', name: 'name'}));
          list.push(Discourse.ExternalNavItem.create({href: 'https://forum.com/t/thread-url/193454#heading--name', name: 'name'}));
        }
        return list;
      }
    });
  </script>
1 Like

does not exist in core anymore. If you want to add items to the top nav menu, you can use this component

7 Likes

Thanks Joe - added!

Only thing is it seems to be stripping out the #jump to?

forum.com/t/thread-url/193454#heading--name

Edit: it seems it’s there and if you copy and pate the URL it works fine, but clicking on it in the nav, it gets stripped out and you just go to the top of the topic. Any ideas why?

1 Like

Sounds like

https://meta.discourse.org/t/deep-linking-to-headings-anchors/47552/36?u=falco

5 Likes

Thanks Rafael, I’m pretty sure it used to work so I’m guessing it’s a recent change…

1 Like

This was tricky to track, but @joffreyjaffeux :mage: added a fix for that here

https://github.com/discourse/discourse/commit/c5140ef3fb3146eb5a580beda254ae2bf4b6002c

It should work if your Discourse is up to date.

5 Likes

Fantastic - it works!!!

Thank you @Johani and @joffreyjaffeux :orange_heart:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.