Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,

I want to list in the content of a page the subpages(menu) under this page.

example of my menu-structure:

Menu1
Menu2 | submenu1|submenu2|submenu3
Menu3

If I click on "Menu2" I will get a list of the submenu 1-3 in my content. Only the menu-titles!

I think it works with childof, but I have no pretty urls.
So, now I have:
Code: Select all
<cms:pages masterpage='index.php'>
    <cms:show k_page_title /> <br>
</cms:pages>


and I get the list:
Menu3
submenu3
submenu2
submenu1
Menu2
Menu1

but what I want is, if I am on site Menu2, a list of the submenus in order:

submenu1
submenu2
submenu3

Please help - many thanks!

guenter
Hi Guenter,

I presume you are using 'nested_pages' to create that menu hierarchy.
Going by that assumption, you can use either of the following tags to get the list of immediate children -
1. menu (http://www.couchcms.com/docs/tags-reference/menu.html)
2. nested_pages (http://www.couchcms.com/docs/tags-refer ... pages.html)

The key, as you mentioned, is the 'childof' parameter.
This parameter takes a special keyword '@' that is very useful in cases such as yours.
Please see 'Dynamic Menu' section at http://www.couchcms.com/docs/tags-reference/menu.html for the complete discussion.
In short:
If you use '@1', it will cause both the tags to list only the children of the current page's topmost parent.
If you use '@current', the tags will list only the children of the current page.
Choose whichever suits you need.
Code: Select all
<cms:menu masterpage='index.php' childof='@1' />

Code: Select all
<cms:nested_pages masterpage='index.php' childof='@1' />
   <a href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a><br />
</cms:nested_pages>

Hope this helps.
KK wrote: The key, as you mentioned, is the 'childof' parameter.
This parameter takes a special keyword '@' that is very useful in cases such as yours.
Please see 'Dynamic Menu' section at http://www.couchcms.com/docs/tags-reference/menu.html for the complete discussion.
In short:
If you use '@1', it will cause both the tags to list only the children of the current page's topmost parent.
If you use '@current', the tags will list only the children of the current page.


Oh yes that´s it - thanks!
I forgot that with nested...

But I still don´t understand the @current for my example above - may be it need a subsubmenu in my example?

So I only want to get the submenu listened when the page is "Menu2" it works for me now:
Code: Select all
<cms:if k_page_id='27' >
<div class="submenu" style="width:100%;height:50px;">
  <cms:menu masterpage='index.php' childof='@1' menu_class='submenu'  />
</div>
</cms:if>


Thanks again

guenter
3 posts Page 1 of 1