Add category to top menu so that category can be landing page


(Jay Pfaffman) #1

Continuing the discussion from Invalid items can be added to the top_menu setting:

Is there an example of how to do this somewhere (that I can’t find)? I think that I want to do something like

<script type="text/discourse-plugin" version="0.8.25">
  api.modifyClass('component:edit-category-settings', {
    availableSorts: Ember.computed(function() {
    let sorts = this._super();
    let voteSort = {};
    voteSort["name"] = "Votes";
    voteSort["value"] = "votes";
    sorts.push(voteSort);
    return sorts;
    })
  });
</script>

except I want to target the top menu component. I’m not sure where to look for it, though.

Edit: And now that I’ve grepped the source for edit-category-settings I’m even more confused. :thinking:


Discourse is feeding js to archive.org again
(Jay Pfaffman) #2

Well, Custom top navigation links will let you add other things to the nav menu, but it won’t let you change the default landing page.

Is there a way to change the default landing page?


(Joe) #3

The homepage is set here:

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/utilities.js.es6#L490-#L507

I believe @tshenry has a theme component that allows you to override the hompage on mobile, but it has fixed options like latest / top / unread.

You can can still re-purpose the code in that component. You can use something like this in the common header section

<script type="text/discourse-plugin" version="0.8">
    const { setDefaultHomepage } = require('discourse/lib/utilities');
    setDefaultHomepage('/c/category-slug'); // <--- set homepage url
</script>

This will override any homepage preferences the user sets, but it should be possible to check those preferences and only force the homepage if the user hasn’t changed that preference.