wishbone Posted March 8, 2013 Share Posted March 8, 2013 It is 'item_current_tpl' Sorry for the confusion, it seems to be wrong in the documentation since near beginning. Interesting nobody recognized it by now. it's still "active" in the github wiki documentation... https://github.com/somatonic/MarkupSimpleNavigation/wiki/MarkupSimpleNavigation-Documentation but thx so much for this work! its great Link to comment Share on other sites More sharing options...
Mats Posted March 10, 2013 Share Posted March 10, 2013 I'd like to add a dynamic parent class based on the page name. Is there a way of doing this at the moment or is it possible to add such a feature? Something like: 'parent_class' => 'parent {name}' or 'active_parent' => true This is such a great module and time saver! Thanks for creating it Soma! Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Author Share Posted March 11, 2013 Hey @mats, can you tell a little more what you want to do or better why, so I can think a little better? Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Author Share Posted March 11, 2013 it's still "active" in the github wiki documentation... https://github.com/somatonic/MarkupSimpleNavigation/wiki/MarkupSimpleNavigation-Documentation but thx so much for this work! its great You're welcome. I can't see where you say, I changed it all I thought. nevermind found it... thx. Link to comment Share on other sites More sharing options...
Mats Posted March 11, 2013 Share Posted March 11, 2013 Hi Soma! I have a news page with sections and sub sections, each section has it's own color which is inherited to it's subsections. When on a sub section i'd like to indicate both the current subsection and the parent section with the section color. Does this make any sense? Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Author Share Posted March 11, 2013 I might add a list field class option string, so you can add fields you want to each <li> item. so you could add whatever classes and do: 'list_field_class' => '{template} p{id}', and it would add this to every page list_tpl. And if left empty (default) it won't output. I think then with this one can cover all aspects a basic navigation needs more or less. 1 Link to comment Share on other sites More sharing options...
Mats Posted March 11, 2013 Share Posted March 11, 2013 Sounds great! Thanks a lot Soma! Link to comment Share on other sites More sharing options...
Soma Posted March 11, 2013 Author Share Posted March 11, 2013 I just commited an update to 1.1.6 While editing the wiki documentation page it somehow was deleted after editing doh! So updated readme a little and copied that to the wiki. `list_field_class` option (new in 1.1.6) You can optionally define custom classes using a string that can contain tags for field names of pages. For example: 'list_field_class' => '{template} p{id}', will add ' basic-page p1001' to each 'list_tpl' class string. 1 Link to comment Share on other sites More sharing options...
Mats Posted March 13, 2013 Share Posted March 13, 2013 Thanks for the update Soma. There seems to be a undefined variable named class in the code (line 238 if i remember correctly). I still would like to be able to set a class on the parent/s like the item_current_tpl, if possible. I think this would it a lot easier to style the navigation. I understand if you're not willing to add it since this kind of feature might have a bit limited use. Link to comment Share on other sites More sharing options...
Soma Posted March 13, 2013 Author Share Posted March 13, 2013 Thanks mats for the heads up. I think It was late when doing this. Have to take a look a again at that $class variable. I should practice what I preach As for the wish, I'm not sure what you mean because you can aleady define what you want: parent_class : class for all active parents has_children_class : class for parents that have children now new list_field_class: add classes like {name} to each item (which is what you need not?) so a active parent of the current page will have <li class="parent has_children about">... I didn't just add this new feature to "parent_class" because adding the possibility to add {fieldname} to all items covers all needs and not just for parents. 1 Link to comment Share on other sites More sharing options...
Mats Posted March 13, 2013 Share Posted March 13, 2013 The thing is i'd like to have only active classes based on the page name. Otherwise it gets kind of messy trying to style the navigation. Here's an example of navigation i'm converting http://lidingosidan.se/stadsplanering/ The site uses this plug in http://textpattern.org/plugins/996/adi_menu Link to comment Share on other sites More sharing options...
Soma Posted March 13, 2013 Author Share Posted March 13, 2013 I dont really get what the problem is. You have the current parent and the section. list_field_class => 'p{id}' Then in css li.parent.p1001{..} Or li.parent.p1001 > a { ..} To style active section item with parent id 1001 1 Link to comment Share on other sites More sharing options...
Mats Posted March 13, 2013 Share Posted March 13, 2013 You're right Soma, it's my css that's messed up and i'm stuck in the old way of styling the navigation. I just have to rethink it. Thanks for all your help! 1 Link to comment Share on other sites More sharing options...
Soma Posted March 13, 2013 Author Share Posted March 13, 2013 If something I learned over the years, it's to watch your css for navigations ... as simple as possible pays out. However since older browsers are left behind it good to move on. I updated the Module to 1.1.7 to fix the warning. Thx for mention. 1 Link to comment Share on other sites More sharing options...
onjegolders Posted March 18, 2013 Share Posted March 18, 2013 Probably a simple thing to do but how would I go about having lowercase letters in the output? Was thinking of using strtolower in the item_tpl but not sure how to approach it. Thanks Soma. Link to comment Share on other sites More sharing options...
Soma Posted March 18, 2013 Author Share Posted March 18, 2013 http://www.w3schools.com/cssref/pr_text_text-transform.asp Link to comment Share on other sites More sharing options...
onjegolders Posted March 18, 2013 Share Posted March 18, 2013 http://www.w3schools.com/cssref/pr_text_text-transform.asp Where has my brain gone? 1 Link to comment Share on other sites More sharing options...
OllieMackJames Posted March 20, 2013 Share Posted March 20, 2013 Newbie question... I donwnloaded this great module, but now run into some trouble, how can I do the following: In order to reduce bounce rate I want to split up longer pages in sub pages. I want to have the following structure for the pages that will be split into more pages topic - topic/page2 - topic/page3 - topic/page4 - topic/page5 then on each of all the pages above I want a clickable TOC just for this topic and its sub pages How to do this so it is as much automated as possible? Link to comment Share on other sites More sharing options...
Soma Posted March 20, 2013 Author Share Posted March 20, 2013 Not exactly sure about the structure but you could try this: If you have /article/ /article/page1 /article/page2 /article/page3 Code on article page $root = $page; echo $nav->render(null, $page, $root); // $nav being instance of the module And on the child pages $root = $page->parent; echo $nav->render(null, $page, $root); $page being the current page and $root is from where it starts generating navigation. Yu could also use the various options available to make adjustments, if not needed you can set it to "null" as in the example. Link to comment Share on other sites More sharing options...
OllieMackJames Posted March 21, 2013 Share Posted March 21, 2013 @Soma, thanks, yes structure like you said is correct /article/ /article/page1 /article/page2 And on each page (article and child I would like to see a snippet as output like the following: <details class="pw-toc" open="open"><summary>In this article</summary><ol> <li><a class="active" href="http://mydomain.com/article/">How Processwire beats any CMS handsdown</a></li> <li><a href="http://mydomain.com/article/page2/">3 Mistakes You Should not make in choosing a CMS</a></li> <li><a href="http://mydomain.com/article/page3/">Can you do this with your current CMS</a></li></ol></details> So if I use on the article page: $root = $page;echo $nav->render(null, $page, $root); // $nav being instance of the module and on the child pages: $root = $page->parent;echo $nav->render(null, $page, $root); What step is then further needed to produce the output like above? Oh and just for anybody's information, stuff like this usually drops your bounce rate in most cases with 20-30% easily, so google clearly loves it, thanks! Link to comment Share on other sites More sharing options...
Soma Posted March 21, 2013 Author Share Posted March 21, 2013 Right with this structure it would look like this: <details class="pw-toc" open="open"> <summary>In this article</summary> <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); $options = array( 'max_levels' => 1, 'current_class' => 'current', 'outer_tpl' => '<ol>||</ol>', 'show_root' => true ); $root = $page->parents->count == 1 ? $page : $page->parent; echo $treeMenu->render($options, $page, $root); ?> </details> The root here is found by counting what level, and either take parent or page itself as the root. -- You could also define root alternatively like maybe depending on the structure and templates: $root = $page->parent->template == 'article' ? $page->parent : $page; echo $treeMenu->render($options, $page, $root); So saying if parent page template is 'article' take current page->parent as root, if not we take current page assuming it's the top 'article' page and not a child. Link to comment Share on other sites More sharing options...
OllieMackJames Posted March 27, 2013 Share Posted March 27, 2013 Soma, thanks lots, that does the trick! Slowly working my way up to some copied skills here with PW!... Link to comment Share on other sites More sharing options...
k07n Posted April 5, 2013 Share Posted April 5, 2013 Hi! Read all thread, but can't solve my problem. My structure: Home -- About -- Something Else -- Want it in menu1 ----Subpage11 ----Subpage12 ---- ..more of them.. -- Want it in menu2 ----Subpage21 ----Subpage22 ---- ..more of them2.. What is the easiest way to render only "Want it in menu 1|2" and their children? I think of excluding all others pages, but pages can grow. How can I just point only 2 of pages to render? Sorry for my English. Hope you understand what I mean. upd: If only be that you can specify multiple parents. Link to comment Share on other sites More sharing options...
Soma Posted April 5, 2013 Author Share Posted April 5, 2013 You can' specify multiple roots, but you can exclude children. $options = array("selector"=>"id!=1003|1004"); echo $navTree->render($options); So the pages with those id's wont be rendered. Or you could add a checkbox custom field to the templates to only include them if checked from the navigation. $options = array("selector"=>"show_in_menu=1"); echo $navTree->render($options); 1 Link to comment Share on other sites More sharing options...
k07n Posted April 6, 2013 Share Posted April 6, 2013 You can' specify multiple roots, but you can exclude children. Thank you, Soma! I'll try to exclude pages by template. 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