CMS Development

abe_pop
Mitglied

Not getting menu from Navigation editor

lösung

Good afternoon all,

 

I am currently building a custom theme for a website, and am in the process of writing a draft. I have built a menu in the Navigation Editor and am trying to make it appear on the webpage. However, for some reason, it is not appearing in either the theme menu or the content creator interface when I drag and drop to create a new menu. The theme so far is an adaptation of the boilerplate code available from HubSpot, and it uses the menu() function in the boilerplate module "menu-section.module."

 

In order to diagnose the issue, I printed module.primary_menu_field and menu(module.primary_menu_field)|pprint. The first one prints out the menu ID correctly. However, the second one (with the menu() function) prints the following:

 

(PageTreeNode: PageTreeNode{label=null, url=null, children=, activeBranch=false, activeNode=false, level=0, pageTitle=null, pageId=null, slug=null, linkTarget=null})

 

After that, the menu itself is meant to be returned in the boilerplate code by:

 

renderNavigation(menu(module.primary_menu_field))

 

But the menu does not appear, I presume because the menu function is returning what appears to be an empty PageTreeNode.

 

Is it possible that somehow HubSpot is not finding the menu from the Navigation Editor? Is there any possible resolutions? Any help would be appreciated. Thank you!

 

Best,
Abe

0 Upvotes
1 Akzeptierte Lösung
dennisedson
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

Not getting menu from Navigation editor

lösung

I believe the issue is that the pages you have in that menu are in a draft state. If you subsituted with published pages, they would appear.

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
6 Antworten
abe_pop
Mitglied

Not getting menu from Navigation editor

lösung

Thank you so much for the clarification. I haven't published any pages yet (they are just called test[N] where N is a number I increment), so that explains why they are not appearing. As I move forward, I will just not make them link to pages until those pages are published, so I can build out the menu accordingly.

abe_pop
Mitglied

Not getting menu from Navigation editor

lösung

Interesting. For the first time, I am seeing something more than nothing. The relevant code (omitting most of the module, which is from the boilerplate) is below:

 

<nav aria-label="Main menu" class="navigation-primary">
  {{ module.primary_menu_field }}
  {{ menu(module.primary_menu_field)|pprint }}
  {{ renderNavigation(menu(module.primary_menu_field)) }}
</nav>

The menu editor and the relevant part of my header partial are shown below:Screen Shot 2021-06-11 at 10.55.08 AM.pngScreen Shot 2021-06-11 at 10.57.12 AM.png

dennisedson
Lösung
HubSpot-Produktteam
HubSpot-Produktteam

Not getting menu from Navigation editor

lösung

I believe the issue is that the pages you have in that menu are in a draft state. If you subsituted with published pages, they would appear.

0 Upvotes
abe_pop
Mitglied

Not getting menu from Navigation editor

lösung

Thank you for your response. I think I do. See the image below:

 

Screen Shot 2021-06-11 at 10.49.37 AM.png

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Not getting menu from Navigation editor

lösung

@abe_pop .

Just for fun, can you add another item that does not have a page associated with it? 

Or an page that is not in draft.  I believe the menu will not print links to pages in draft mode

0 Upvotes
dennisedson
HubSpot-Produktteam
HubSpot-Produktteam

Not getting menu from Navigation editor

lösung

@abe_pop ,

The pprint makes it appear like there are no items to print for the menu.  Do you have items (not draft) in the menu?

0 Upvotes