Jump to content

building navigation menu beyond the page tree list structure


adrianmak
 Share

Recommended Posts

For a complex site, it is not the case the navigation is stick on the page tree list hierarchy structure.

The navigation menu link may be from different section of a site.

I knew there is a pw menu builder module, drag and page freely to build a navigation menu.

However, the module is a bit too much of feature provided for user.

I could find an alternative solution using the pw code Page field type.

You can add another pages. However the main cons of page field is , it only represent first level of navigation, it cannot present sub-level.

That's all page add into the page field are on the same level

Page field

page1

page2

page5.1

page5.2

page5.3

page3

page4

From page field , page5.1, 5.2, and 5.3 are on same level, but they are child of  page2.

So, When I transverse the page array, I could not build a menu item with child menu items

Link to comment
Share on other sites

I don't think this would be easy unless using the menu builder module. I also don't think that it is a good idea to build your site structure like this. Have you thought of deviding your tree in one branch "menu" and one branch "helpers" or "options" or "data"? Maybe this would make things easier. You can than rewrite the URLs from example.com/menu/page1 to example.com/page1

I'm on mobile... Use Google and you will find how to do that :)

  • Like 1
Link to comment
Share on other sites

Building menus for any usage has been discussed a lot over the years.

Here's one post:

https://processwire.com/talk/topic/2787-custom-menu-not-related-to-page-tree/#entry27275

In the end, i have found that having a branch on the page tree for the menu is the most flexible and easiest to:

- code custom navs from (mega menus, boostrap etc)

- publish/unpublish menu items

- use permissions for menu items (e.g. show some menu items to logged in users)

- insert stuff like forms, videos etc into a menu

and it works very well with MSN (markup simple navigation) because it allows you to set the parent...

  • Like 6
  • Thanks 1
Link to comment
Share on other sites

  • 4 years later...

I've been ressearching for all various approaches to start a mega menu with clickable categories on the left and a few query results to the right, so initially thought of having pure PW markup with selecting pages and including my menu markup, but then found this post and I must admit that the approach of @Macrura seems very much the one I would like to try. Having done that structure, I can organize my menu the way I want and still be able to re-organize it without touching the code once done. Not to mention that it would also work with multilanguage just because every menu would support it.
For sure for simple dropdowns I would use MenuBuilder which works OOB and deliver, but I am not yet finding a way to have a custom markup menu with it (besides changing styles and menu layout a bit).

Link to comment
Share on other sites

8 minutes ago, Motion Expert said:

For sure for simple dropdowns I would use MenuBuilder

Actually you can use MenuBuilder for very complex menus by using the getMenuItems() feature 😉. You could even use Macrura's recursive function with it (adapted, of course).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...