webweaver Posted December 24, 2013 Share Posted December 24, 2013 I know this must be simple, but I'm having a heck of a time trying to figure this out. I want to add a menu into a page that shows the children of that page. In other words, this page is just a container page of the sub pages and I want to display those sub pages as a menu inside the current page. Please Help Link to comment Share on other sites More sharing options...
webweaver Posted December 24, 2013 Author Share Posted December 24, 2013 I guess this was quite easy to do w/out MarkupSimpleNavigation... <?php echo "<ul>"; foreach($page->children as $child){ echo "<li><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>"; ?> Link to comment Share on other sites More sharing options...
Soma Posted December 24, 2013 Share Posted December 24, 2013 If you read the manual you'll find that the last argument you can specify the root parent page... that would be simply the current $page. Link to comment Share on other sites More sharing options...
webweaver Posted December 24, 2013 Author Share Posted December 24, 2013 Soma, I was trying to do that but couldn't figure out exactly how - I'm still pretty new at this For example, I tried this with no success: <?php $treeMenu = $modules->get("MarkupSimpleNavigation"); $rootPage = $page; $options = array( 'parent_class' => 'parent', 'current_class' => 'current-menu-item', 'has_children_class' => '', 'levels' => false, 'levels_prefix' => '', 'max_levels' => 2, 'firstlast' => false, 'collapsed' => false, 'show_root' => false, 'selector' => '', 'selector_field' => 'nav_selector', 'outer_tpl' => '<ul class="dl-menu">||</ul>', 'inner_tpl' => '<ul class="dl-submenu">||</ul>', 'list_tpl' => '<li%s>||</li>', 'list_field_class' => '', 'item_tpl' => '<a href="{url}">{title}</a>', 'item_current_tpl' => '<a href="{url}">{title}</a>', 'xtemplates' => '', 'xitem_tpl' => '<a href="/{url}">{title}</a>', 'xitem_current_tpl' => '<a href="/{url}">{title}</a>' ); echo $treeMenu->render($options,$rootPage); ?> Link to comment Share on other sites More sharing options...
Soma Posted December 24, 2013 Share Posted December 24, 2013 You have the rootPage as second argument. Insert null as second, this is to overwrite current page active. Link to comment Share on other sites More sharing options...
webweaver Posted December 24, 2013 Author Share Posted December 24, 2013 ahah! Thank you! Link to comment Share on other sites More sharing options...
Soma Posted December 25, 2013 Share Posted December 25, 2013 Just to make it complete with a working example (now at desktop): $treeMenu = $modules->get("MarkupSimpleNavigation"); $rootPage = $page; $options = array( 'current_class' => 'current-menu-item', 'has_children_class' => '', 'max_levels' => 2, 'outer_tpl' => '<ul class="dl-menu">||</ul>', 'inner_tpl' => '<ul class="dl-submenu">||</ul>', 'item_tpl' => '<a href="{url}">{title}</a>', 'item_current_tpl' => '<a href="{url}">{title}</a>', ); echo $treeMenu->render($options, null, $rootPage); Link to comment Share on other sites More sharing options...
Martijn Geerts Posted December 25, 2013 Share Posted December 25, 2013 @Soma: feature request Remove Indentation, not rendering tabs newlines & other unnecessary white-space characters. Lot's of time, ill remove them with regex, but hey, i'm lazy... Link to comment Share on other sites More sharing options...
Soma Posted December 26, 2013 Share Posted December 26, 2013 @Soma: feature request Remove Indentation, not rendering tabs newlines & other unnecessary white-space characters. Lot's of time, ill remove them with regex, but hey, i'm lazy... Not the right thread but I hear you. 1 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