KentBrockman Posted May 24, 2013 Share Posted May 24, 2013 Soma, what a great module! Is it possible to highlight the whole "navigation-path" to the current page?Means that all of the parents need to get the 'current' class too. - Level1 - Level1 -- Level2 --- Level 3 - Level 1 I didn't found any related posts to this question.Thank you for all your efforts. Link to comment Share on other sites More sharing options...
Soma Posted May 24, 2013 Author Share Posted May 24, 2013 There is, the parent option add classes to all parents. 1 Link to comment Share on other sites More sharing options...
KentBrockman Posted May 24, 2013 Share Posted May 24, 2013 Oh oh oh, so easy! My fault. Thank you for the fast reply. Link to comment Share on other sites More sharing options...
marcus Posted May 30, 2013 Share Posted May 30, 2013 Hi and once again a newbee question from me... For some reason I am not able to make the following code work. It outputs the navigation not from page 1001 but from the real root, page 1. And I'm scratching my head asking why... <?php $teaser1 = $modules->get("MarkupSimpleNavigation"); $options = array( 'levels' => false, 'max_levels' => 1, 'show_root' => false ); $rootTeaser1 = $page->get(1001); echo $teaser1->render($options, null, $rootTeaser1); ?> Can you help me finding out why it ignores my custom root? And yes, 1001 does exist and has non-hidden children nodes. Thanks in advance! Marcus Link to comment Share on other sites More sharing options...
Soma Posted May 30, 2013 Author Share Posted May 30, 2013 It should be $pages->get (1001) Link to comment Share on other sites More sharing options...
arjen Posted May 30, 2013 Share Posted May 30, 2013 Try: $rootTeaser1 = $pages->get(1001); Link to comment Share on other sites More sharing options...
marcus Posted May 30, 2013 Share Posted May 30, 2013 *facepalm* Thanks! Arrghh.... Link to comment Share on other sites More sharing options...
KentBrockman Posted June 3, 2013 Share Posted June 3, 2013 Sorry, it's me again, but i don't get it. I need to render the Nav for a defined set of ids (eg. id=1015|1016|1017|1018). I'm not sure how to set the selector right. Even if i only use one page via id|has_parent the module is not rendering thru the levels.What am i doing wrong?Thanks! Link to comment Share on other sites More sharing options...
Soma Posted June 3, 2013 Author Share Posted June 3, 2013 On 6/3/2013 at 7:05 AM, KentBrockman said: Sorry, it's me again, but i don't get it. I need to render the Nav for a defined set of ids (eg. id=1015|1016|1017|1018). I'm not sure how to set the selector right. Even if i only use one page via id|has_parent the module is not rendering thru the levels. What am i doing wrong? Thanks! I'm not sure what you're trying, but the module expects a "root" page from where it renders the children of that page. On a side note "has_parent" only accepts one id and only makes a difference if the parent is one of the children of the root page. To understand a little better, can you explain what you want with those id's? Are those the only page that should show up, or are they the "parents" from where it should render a nested navigation? Link to comment Share on other sites More sharing options...
KentBrockman Posted June 3, 2013 Share Posted June 3, 2013 Hard to explain. Let's say we got the following constellation: Root (1000) - Level1 (1001) - Level1(1002) - Level1(1003) -- Level2(1011) --- Level 3(1021) - Level1(1004) - Level1(1005) And now i need to render the navigation including all subnavigations for the ids 1002, 1003, 1004. It has to be "hardcoded" via ids because have no other chance to differentiate between the the pages on level 1. If i call the module three times with other rootpages, it works. But isn't there a better way to do only one rendering call by using the selector option? Thank you for your support. Link to comment Share on other sites More sharing options...
Soma Posted June 3, 2013 Author Share Posted June 3, 2013 I'm not sure I understand, but can't you just set them "hidden"? The include this and that ID approach won't work with hierarchical tree of course, but exclude would. "id!=1001|1005" "parent=1002|1003" would also work but only for direct children. "has_parent=1002" only works for 1 parent, but would include all children levels. So best option is the one built for such things, make the pages "hidden". Link to comment Share on other sites More sharing options...
marcus Posted June 3, 2013 Share Posted June 3, 2013 I'm wondering: is there a way to influence the parent item - like it's possible to influence the current one? A counterpart of "item_current_tpl", such as "item_parent_tpl"? Link to comment Share on other sites More sharing options...
KentBrockman Posted June 3, 2013 Share Posted June 3, 2013 Soma, my explanation wasn't the best, so i think we are talking past each other. But never mind, i'm now excluding the ids i do not need. It's more or less a workaround, but it works perfect. Thank you. Link to comment Share on other sites More sharing options...
Soma Posted June 3, 2013 Author Share Posted June 3, 2013 If you think I missunderstood, why not show what the result should be like? I think I understood what you want and showed what parent and has_parent does. There's so many ways to archive something there might be a better solution. You could for example add checkbox to top level pages and use that instead of making the top level pages you dont want to show hidden. Link to comment Share on other sites More sharing options...
KentBrockman Posted June 3, 2013 Share Posted June 3, 2013 Soma,thank you for not giving up on me! My "wish" is still to have an defined array of "parent-ids" and the module should render the navigation for only these ids including all subnavigations in one call.Let's say we have the following structure:Home/Root- Company-- About-- Team- Products-- Category 1--- Subcategory 1--- Subcategory 2-- Category 2--- Subcategory 1--- Subcategory 2- Services-- Service 1--- More services 1--- More services 2- Directions- Contact- ImpressThis is the whole navigation tree and it's used all over the website. In some special cases i only want to show the navigation for Products and Services.My simple snippet $ids = "1015,1016"; $navigationHeaderMain = $pages->getById($ids); foreach($navigationHeaderMain as $nht) { $customRoot = $pages -> get($nht->id); echo $treeMenu -> render($options, $page, $customRoot); } doesn't work out, because it will output two lists <ul><li>Products... <ul><li>Service... and even if i set show_parent to true the "root" (Products, Service) are not included correct in the list.Can you follow?If it is possible to set a flag (checkbox) like "add this page to my customNavigation" as you mentioned in your post, it would be perfect! But what is the correct statement for the 'selector'? I have no clue.Thank you so much for all your efforts! Link to comment Share on other sites More sharing options...
Soma Posted June 3, 2013 Author Share Posted June 3, 2013 Ah I think you're best off with setting the outer wrapper template to '||' and add opening and closing UL after. I then also think it would be nice to have a include in the top level thing.. and if has_parent would allow multipe it would already be easy... have to think a little more. With checkboxes it would still be the same issue with parents. 1 Link to comment Share on other sites More sharing options...
spoetnik Posted June 4, 2013 Share Posted June 4, 2013 Any thoughts on how to use this module together with your LanguageLocalizedURL Module?? Link to comment Share on other sites More sharing options...
Soma Posted June 4, 2013 Author Share Posted June 4, 2013 On 6/4/2013 at 11:42 AM, spoetnik said: Any thoughts on how to use this module together with your LanguageLocalizedURL Module?? There's nothing special about it, it just works. Page url is localized automaticly by current user language. Link to comment Share on other sites More sharing options...
Soma Posted June 4, 2013 Author Share Posted June 4, 2013 On 6/3/2013 at 4:36 PM, marcus said: I'm wondering: is there a way to influence the parent item - like it's possible to influence the current one? A counterpart of "item_current_tpl", such as "item_parent_tpl"? Why do you want this anyway? The current parents are already marked with a class you can define. Default "parent". I'm not too excited to add another template option, as we will have a new option every other week someone thinks this would be useful. However, for that reason I created a function (getTagsString) you can hook into to change a child's output. There's some example further up this thread, but just to give another example: $nav = $modules->get("MarkupSimpleNavigation"); function hookTagString(HookEvent $event){ $child = $event->arguments('page'); // current child in navigation $parents = wire("page")->parents; // parents of current page if($parents->has($child)){ // is current child an active parent? $event->return = "<span class='parent'>$child->title</span>"; // return something } } $nav->addHookAfter('getTagsString', null, 'hookTagString'); echo $nav->render(); 1 Link to comment Share on other sites More sharing options...
marcus Posted June 5, 2013 Share Posted June 5, 2013 Hi Soma, thanks for this approach! I was kind of thinking out loudly - I hope it wasn't understood as a feature request and totally can understand that you aren't looking forward to adding every special request into the module core. I'll try to implement a hook like this - thanks again for pushing me in the right direction! Best, m Link to comment Share on other sites More sharing options...
onjegolders Posted June 12, 2013 Share Posted June 12, 2013 Hi Soma, Any possibility of a has_parent class? Link to comment Share on other sites More sharing options...
Soma Posted June 12, 2013 Author Share Posted June 12, 2013 On 6/12/2013 at 1:02 PM, onjegolders said: Hi Soma, Any possibility of a has_parent class? Huh? Do you mean the "parent_class" ? https://github.com/somatonic/MarkupSimpleNavigation/blob/master/MarkupSimpleNavigation.module#L26 1 Link to comment Share on other sites More sharing options...
onjegolders Posted June 13, 2013 Share Posted June 13, 2013 Sorry Soma, Is that not the class for the parent itself, I was looking for a class for the child of a parent. Only ask I was having trouble targetting a specific "option" for a mobile nav. (I did read the docs I promise ) Link to comment Share on other sites More sharing options...
Soma Posted June 13, 2013 Author Share Posted June 13, 2013 I have trouble understanding what you want and why? A child of a parent? Link to comment Share on other sites More sharing options...
kongondo Posted June 13, 2013 Share Posted June 13, 2013 Home Child 1 (child of parent ) - class for this....and more below... Grandchild 1 1 (another child of parent , so etc. ) Great grandchild 1 1 1 Grandchild 1 2 Child 2 Grandchild 2 1 A child class will potentially cause conflict with parent and has_children classes in cases where children are themselves parents CSS maybe? 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