kgish
(Kgish)
September 1, 2016, 11:59am
1
I’m developing a plugin which needs to be able to append an extra button to the top navigation bar:
list-controls > .container > div > .ul.nav
I also need to remove the new-topic button at the far right.
What is the proper way to do this? Plugin.rb? Javascript?
cpradio
(cpradio)
September 1, 2016, 12:25pm
2
You could hide the New Topic button via CSS and to add navigation you can do that in the Customize JavaScript sections. See the below post as an example (there are others in that topic too)
Why not just add a navigation page that lists all topics with zero replies? The query exists… adding it to the navigation is trivial…
Why does it have to nag me?
Adding this to the </body> in your Customize, creates an Unanswered navigation tab
<script>
Discourse.ExternalNavItem = Discourse.NavItem.extend({
href : function() {
return this.get('href');
}.property('href')
});
I18n.translations.en.js.filters.unanswered = { title: "Unanswered", help: "Topics that have not be …
2 Likes
kgish
(Kgish)
September 1, 2016, 9:07pm
3
CSS will not work, so I resorted to the following solution which I happed to find elsewhere on the forum:
Discourse.ExternalNavItem = Discourse.NavItem.extend({
href : function() {
return this.get('href');
}.property('href')
});
// Add navigation button 'Mijn berichten'
Discourse.NavItem.reopenClass({
buildList : function(category, args) {
console.log(`NavItem#buildList(), category="${category?category.get('name'):'null'}", args="${JSON.stringify(args)}"`);
var list = this._super(category, args);
if (!category && args.filterMode !== 'posted') {
console.log('NavItem#buildList() => add posted button ');
list.push(Discourse.ExternalNavItem.create({href: '/posted', name: 'posted'}));
}
return list;
}
});
cpradio
(cpradio)
September 1, 2016, 9:11pm
4
kgish:
CSS will not work
It should for hiding the New Topic button, but for adding links, you are correct, it won’t which is why I linked to that topic (to show you how to add buttons)