Idea: Category as external link


(Erik Manger) #1

Hey everyone,

I would like to suggest the idea of having categories as external links. My Discourse site works in conjunction with other websites and having this option would suffice greatly.

I’m sure it isn’t too hard to achieve in terms of coding.

Thanks!

Erik


(Allen - Watchman Monitoring) #2

Do you mean like:

or even https://meta.discourse.org/category/feature ?


(Erik Manger) #3

Like, having a category on the index… and when it is clicked, it leads to an external link instead of a forum.


(Logan Mathews) #4

That really isn’t the purpose of the category type though. You might want to consider adding it to one of the existing more appropriate contexts on the site.


#5

I also support this feature and use it in my current VB based forum for a Business Directory that is implemented using another system.

Presenting the “Business Directory” as just another category in the forum makes it intuitive to the user, and the link allows me to send them to the right place.


(Kane York) #6

Meta has a customization that you can probably adapt for that:

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

  I18n.translations.en.js.filters.bugs = { title: "Bugs", help: "Open Bugs" };
  I18n.translations.en.js.filters.features = { title: "Features", help: "Open Feature Requests" }

  Discourse.NavItem.reopenClass({
    buildList : function(category, args) {
      var list = this._super(category, args);
      if(!category) {
        list.push(Discourse.ExternalNavItem.create({href: '/category/bug?order=op_likes&status=open', name: 'bugs'}));
        list.push(Discourse.ExternalNavItem.create({href: '/category/feature?order=op_likes&status=open', name: 'features'}));
      }
      return list;
    }
  });
  </script>

(Jeff Atwood) #7

Just add a links to your global nav as needed via HTML, in Admin, Customize.


(Erik Manger) #8

How would I do this?


(Jeff Atwood) #9

There is an example in the READ ME FIRST: Admin Quick Start topic included on every Discourse install. Read through that.