adrianmak Posted April 25, 2016 Share Posted April 25, 2016 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 More sharing options...
bernhard Posted April 26, 2016 Share Posted April 26, 2016 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 1 Link to comment Share on other sites More sharing options...
Macrura Posted April 26, 2016 Share Posted April 26, 2016 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... 6 1 Link to comment Share on other sites More sharing options...
You People Posted December 1, 2020 Share Posted December 1, 2020 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 More sharing options...
kongondo Posted December 1, 2020 Share Posted December 1, 2020 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 More sharing options...
You People Posted December 1, 2020 Share Posted December 1, 2020 Thanks @kongondo Will have to try it out then. I thought that the menu builder can be used only for simple dropdowns but boy I was wrong. Have you got a sample code to use for starter with getMenuItems() feature? Link to comment Share on other sites More sharing options...
kongondo Posted December 1, 2020 Share Posted December 1, 2020 14 minutes ago, Motion Expert said: Have you got a sample code to use for starter with getMenuItems() feature? Yes. Please see the links to the gists found here in the documentation. For any further MB-related questions, please post in its support forum. Link to comment Share on other sites More sharing options...
You People Posted December 1, 2020 Share Posted December 1, 2020 @kongondo Thanks again and yes, absolutely. If any questions appear, will post to the proper topic. No need to flood every topic with details. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now