Where can I find the template for navigation?


(Joe) #1

I am trying to create a column layout based on Angus’s incredible plugin.

He’s done a really great job documenting how to create widgets that can be added to his plugin that would fit nicely on the side of the main content. The widgets can use native Discourse code and everything will fit just fine.

I spent a bunch of time looking through git hub trying to find the template part that generates the navigation menu so I can use it to create a widget.

Here’s the navigation menu that I want to recreate:

Here’s why I need to move the menu to a widget (overlaps with content - border added for demo):

And ideally, I’d like to move to somewhere like this (rough sketch):


Like I said, Angus has done a really good job at documenting how to create widgets.

All I want is a bit of help in finding the part of Discourse code that generates the navigation menu so I can adapt it into a widget.


(Joe Buhlig) #2

Give this a try:

You’ll need to do some work to get the data passed to your widget correctly but otherwise the default version is likely what you want.


(Joe) #3

Thank you so much @joebuhlig Can’t believe I missed that :grin:

I will make sure I update this if I get anywhere without breaking things - but don’t hold your breath :upside_down_face:


(Joe Buhlig) #4

I do this quite a bit with custom homepages that I do for folks. They usually want a custom page but also want the navigation bar to remain. So I create a home.hbs file that mimics the default navigation template and set up the controller for it like so:

import NavigationDefaultController from 'discourse/controllers/navigation/default';

export default NavigationDefaultController.extend();

You’ll also need to tell your route to use this template and tell it where it goes. So something like this in your route:

const DiscoveryHomeRoute = Discourse.Route.extend({
  renderTemplate() {
    this.render("navigation/home", { outlet: "navigation-bar" });
    this.render("discovery/home", { outlet: "list-container" });
  }
})

export default DiscoveryHomeRoute;

(Joe) #5

Oh man! This is beyond amazing. I really appreciate it @joebuhlig :star_struck:

I’ve taken the basic first steps in preparing the widget - based on Angus’s other widgets - and wanted to test the basics before I go anywhere “deeper” - and I also need to read a bit more - but alas I don’t have SSH access at the moment - :upside_down_face:

This will most end up causing a failure.

Don’t install this. There’s nothing here.

for reference only

Will update accordingly