Can we make the tag like a menu? and the client can search all tag if they want?


(Vu Hoang) #1

I see the tag like a select box look difficult for the client to choose the topic. So, can we move it to the menu and the client can search the tag that they want?
Thanks! :slight_smile:


(Daniela) #2

Try this script (changing the URL) under Theme > Common > Body, to add “Tags” on menu

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

  I18n.translations.en.js.filters.tags = { title: "Tags", help: "tags list" };
  
  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);

      if(!category) {
        list.push(Discourse.ExternalNavItem.create({href: 'http://your-forum-url.com/tags', name: 'tags'}));       
        
      }
      return list;
    }
  });
</script>

After that you can disable the tags box in your site settings.


(Daniela) #3

I forgot something.

If your site is NOT in english change en in this line with your language abbr. :

I18n.translations.en.

and you can change also Tags and tags list in your language

{ title: "Tags", help: "tags list" }

(Vu Hoang) #4

Hi @Trash
Thanks for your answer, your mean i need add js to “edit css/html” on my theme.right?


(Daniela) #5

Yes, or create and add a separate stylesheet (for example the way you’ve done with “banner” in your screenshot) so you can use this script in more themes (Default and Dark) as a component.