Building a multilevel Navigation - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: Developer Discussions (http://get-simple.info/forums/forumdisplay.php?fid=8) +--- Thread: Building a multilevel Navigation (/showthread.php?tid=105) |
Building a multilevel Navigation - StilgarBF - 2009-08-27 Hi, first I want to say how great this project ist. After only 2 Minutes of reading through the Docu it seams clear how to build a complete Theme. - you really keep it simple here. What I miss in GetSimple is an easy way to build a multilevel navigation. There is a way to create the structure in the backend, but none to print it out in the frontend. WHat I want to do is building a top-level with Home, private, work, contact - and under private there would be images, links ... the later should only be visible if the user is somewhere in "private" As far as I know the only way to do this is by using menu_data('p'), (with a slug that not exists) to get the complete structure of my site. Next step is to loop through the array to build a navigation structure, check for Pages where (parent-slug == [current slug]) or (parent_slug == [current page parent_slug]) and print out the subnavigation. What is the best way to get the complete list? using an undefined slug seems hacky to me. Why can't I ask for the menudata under a specified parent? (menu_data('private/') or menu_data('private') won't give me what I expect. there is a very rapid update-cycle for getSimple at the moment. Can we expect thet multilevel-navigations will be supported out of the box in near future? thanks and greetings Stil Building a multilevel Navigation - StilgarBF - 2009-08-27 I hacked something together which does what I need:
2 problems had to been worked around :
I added the classnames as they are used in GetSimple - every list entry has class="slug" and "current" if selected. I'm not a PHP guru - some things my have been done in better ways - let me know about possible optimization. EDIT - don't use this - see my later post http://get-simple.info/forum/viewtopic.php?pid=1107#p1107 Code: <ul class="lvl_1"> hope that helps others. @GetSimple : keep doing your great work - maybe solve the index->noSlug problem ;-) Building a multilevel Navigation - yxcvbnm - 2009-08-28 hi, thanks for your post... after reading your thread, I looked into the code and didn't understand why menu_data() only answers the menu data if the menu is marked as "Add to Menu?" on line 188 in theme_functions.php Code: if ($page['menuStatus'] == 'Y' && $page['private'] != 'Y') { ... } so i changed it to: Code: if ($page['private'] != 'Y') { ... } i modified your code, writing a small function which gets the slug-id and responds with the children-slugs Code: function get_submenu_data($id) { a developer can write a wrapper function and use that for rendering the submenu Building a multilevel Navigation - ccagle8 - 2009-08-28 Thank you guys for your code... the menu_data() function is still in it's infancy, and may change slightly from what is currently distributed with version 1.5. I would be cautious where you use this function because of that. This is the only function in this stage as it was added in 1.5 with no intention of it being used - i just accidentally mentioned it in one post, and now it has taken off... Building a multilevel Navigation - hopethisusernameisgood - 2009-09-21 @Chris: Any changes to this in the newer versions? Tried to add pages with a parent page and saw that there is no multi-level navigation yet. Hope this can be added or is there a chance to include some own plugins? @StilgarBF: Thanks for your post, added this and the naviagation works fine. Even though i was feeling a bit that i will need another level at some time, and don't know currently how to fix this. Currently your code displays all post, just thrown into an array of <li> points. I do not know much about the menu_data() function, but is there a possibility to display the list points in a certain order? Thanks for your help, Mike Building a multilevel Navigation - ccagle8 - 2009-09-27 menu_data() is not set up to automatically give you multilevel navigation. It just provides all the data needed... Building a multilevel Navigation - andymci - 2009-10-19 I was wondering about this myself, and I ended up crafting a workaround for a client project. Each primary section of the site has its own template. Within that template, I used a component that included the sub-navigation for that particular section. So the "widgets" section includes a component called "widgets-nav", for example. And then "gadgets" gets "gadgets-nav", and so on. It's not the prettiest thing (and definitely not scalable, but GS is for small sites, not large). If you're comfortable with the system and know that you won't be changing your navigation structure on a regular basis, it should be sufficient. Building a multilevel Navigation - StilgarBF - 2009-10-19 I reused my original-code (first post) with a version 1.7 site and found that menu_data() is not returning all data. ['slug'] is allwas empty. 'url' does not contain a slug so this url is unusable. am I doing something wrong? my code is a simple: Code: <pre> Building a multilevel Navigation - wizzy - 2009-10-20 StilgarBF Wrote:I reused my original-code (first post) with a version 1.7 site and found that menu_data() is not returning all data. ['slug'] is allwas empty. 'url' does not contain a slug so this url is unusable. am I doing something wrong? my 1.7 works with that empty syntax, but please try this - using a slug that does really NOT exist: Code: <?php var_dump(menu_data("doesnotexist")); ?> Building a multilevel Navigation - Alexey - 2009-10-22 I have same problem! Slug is empty Anybody have a decision? Building a multilevel Navigation - StilgarBF - 2009-10-22 Alexey Wrote:I have same problem! I patched theme_function.php (/admin/inc/) to make my multilevel-navigation work. I give no guarantee this won't make any problems elsewhere: Code: starting from line Line 203 my multilevelnavi has changed completely: Code: <ul id="navigation"> Now this shows the subcategories even if you are IN the subcategory It highlights the current subcategory and the parent category. It's working only for 2 levels (root and one sublevel) Once again I can not guarantee this will work under al circumstances. It's a bit quick'n dirty I know - needed to finish this. If anyone has ideas how to improve this - let me know. Stil Building a multilevel Navigation - Alexey - 2009-10-22 @Stil Thank you! I found decision! And finalize now my dropdown menu Here is pict Building a multilevel Navigation - n00dles101 - 2009-10-22 This could easily be achieved by returning the data as XML from "menu_data()" as added in 1.7 and using xpath to query the results ... You'll need to add code to check for current pages and add style ti the lists... Code: // returns menu with submenus Mike. edit. just changed the variable names... Building a multilevel Navigation - StilgarBF - 2009-10-22 n00dles101 Wrote:This could easily be achieved by returning the data as XML from "menu_data()" as added in 1.7I'll give this a try - looks smart! thx Building a multilevel Navigation - Patricia - 2009-11-01 n00dles101 Wrote:This could easily be achieved by returning the data as XML from "menu_data()" as added in 1.7 Hi n00dles101, sorry if this is a stupid question can you tell me where exactly I should insert the latest code (your post October 22nd just above) and is that the only modification (beside css change to style <ul> <li> of course) ? many thanks in advance for your help Building a multilevel Navigation - n00dles101 - 2009-11-07 Hi Patricia, You could just put it directly into your template.php, and replace the call to <?php get_navigation(); ?> adn replace it with: Code: <?php I would instead put it in the theme functions file as a function and call that instead. Mike. Building a multilevel Navigation - Patricia - 2009-11-07 I thank you very much, this is actually what I did the first time, but as I didn't manage so I asked my previous question. in my pages I have the home page, the page 2, and "page-22-sub" as child of page2 so I added this new function to the admin/inc/theme_functions.php Code: function get_fullnavigation($currentpage) { but I get this menu (not even showing Home anymore) Code: <ul id="nav"> but the correct menu code should be something like: Code: <ul id="nav"> for info, with the original get_navigation, I get : Code: <ul id="nav"> so the replacement code: - do not insert <a> tags, --> missing the link - miss the home page - do not nest sub <ul> inside the parent <li>, and add unnecessary <li></li> or maybe I missed something? (where/what)? I know it should be easy to modify... but for me a simple change will take hours (days ) LOL I will look into it anyway thx again Building a multilevel Navigation - yxcvbnm - 2009-11-07 another small request for the multi-level navigation: the parent slug of the current can't be highlighted via css if the current slug is a child of the parent (getsimple 1.7, admin/inc/theme_functions.php, line 326) Code: if ("$currentpage" == "$url_nav") { so, i changed this line to the following... now, the parent slug of a current gets the 'current'-css-class, too Code: $menudata = menu_data($currentpage); ccagle8: for usability reasons, it would be nice to have it. could you accept that for next version of gs? Building a multilevel Navigation - homershines - 2009-11-10 Can someone post the final working code? When a post gets long, with many revisions and add-ons, it's easy to get lost. Thanks. homershines Building a multilevel Navigation - Texta - 2009-11-13 Yes, I agree, thanks guy for the code. But someone needs (please) to pull this together. Too me it's (at the moment) a bit unclear which code to use ans which modification to make AND how to call the nav-menu in the end. For example, I just get "sublevel"-menu-entries for the top-pages and NOT the sub-pages. Very strange. for example starting on the Top-Page1: Code: -Top-Page1 Code: -Top-Page1 When changing to a sub-page, just the top-pages get diplayed in the menu. Still trying to figure it out (new to php), but would be nice if someone could put this together and give a short example. Thank you! Building a multilevel Navigation - Zegnåt - 2009-11-17 homershines Wrote:Can someone post the final working code? Texta Wrote:Yes, I agree, thanks guy for the code. But someone needs (please) to pull this together. Can't give you the exact code they have been talking about here, but I can give you mine. As I just published it here on the forum. Building a multilevel Navigation - Texta - 2009-11-17 Thank you very much, Zegnåt! |