Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hello

Is it possible to include a menu class in a nested pages menu. The class would be defined using an editable name in the page template.

e.g:

Code: Select all
<cms:template title='Pages' clonable ='1' nested_pages='1'>
   <cms:editable type='reverse_relation' name='product_photos' masterpage='gallery.php' field='photo_product' anchor_text='View images' label='Gallery' />
   <cms:editable name='main_content' type='richtext' label='Main Content' />
   <cms:editable name='page_class' type='text' label='Page Class For Menu' />
</cms:template>
Hello Nick,

Instead of cms:menu, you can use cms:nested_pages tag to hand-craft the menu.
This way you'll have total control on what you want to use in the marhup.

You can see an example of using cms:nested_pages to generate a menu here - http://www.couchcms.com/docs/tags-refer ... pages.html

Quoting from the page mentioned above -
Code: Select all
<cms:nested_pages masterpage='index.php' extended_info='1' >
   <cms:if k_level_start >
      <cms:if k_level='0'>
          <ul class="my-menu-class-1 my-menu-class-2" id="my-menu-id">
      <cms:else />
          <ul>
      </cms:if>
   </cms:if>
   
   <cms:if k_element_start >
      <li id="item-<cms:show k_nestedpage_name />" class="level-<cms:show k_level/><cms:if k_total_children> has-submenu</cms:if><cms:if k_first_child> first</cms:if><cms:if k_last_child> last</cms:if><cms:if k_is_active> active</cms:if><cms:if k_is_current> current</cms:if>">
      <a href="<cms:show k_menu_link />"><cms:show k_menu_title /></a>
   </cms:if>
   
   <cms:if k_element_end ></li></cms:if>
   <cms:if k_level_end ></ul></cms:if>
</cms:nested_pages>

You can easily use your own variables in the 'class' of <LI> as shown above.

Hope it helps.
Sorry but that's not quite what I meant. Is it possible to achieve a menu like this, possibly by setting the class on the edit page using an editable region?:

For example:
Code: Select all
<li class="<cms:show k_page_?????? />"><a href="<cms:show k_menu_link />"><cms:show k_menu_title /></a></li>


Code: Select all
<ul>
   <li class="style-one"><a href="#" title="#">#</a>
      <ul class="dropdown-menu" role="menu">
         <li class="style-two"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
         <li class="style-one"><a href="#" title="#">#</a></li>
      </ul>
   </li>
   <li class="style-one"><a href="#" title="#">#</a></li>
   <li class="style-one"><a href="#" title="#">#</a></li>
   <li class="style-two"><a href="#" title="#">#</a></li>
   <li class="style-one"><a href="#" title="#">#</a></li>
   <li class="style-one"><a href="#" title="#">#</a></li>
</ul>
Oh I think I understood precisely what you meant, Nick.
To customize the menu (like adding the class you mentioned) you'll have to use cms:nested_pages.

Following code should output the exact markup you gave (including using the 'page_class' editable region's value as class). Make sure to change the 'masterpage' parameter first.
Code: Select all
<cms:nested_pages masterpage='your-template-here.php' extended_info='1' include_custom_fields='1'>
    <cms:if k_level_start >
        <cms:if k_level='0'>
            <ul>
        <cms:else />
            <ul class="dropdown-menu" role="menu">
        </cms:if>
    </cms:if>
   
    <cms:if k_element_start >
        <li class="<cms:show page_class />"><a href="<cms:show k_menu_link />" title="<cms:show k_menu_title />"><cms:show k_menu_title /></a>
    </cms:if>

    <cms:if k_element_end ></li></cms:if>
    <cms:if k_level_end ></ul></cms:if>
</cms:nested_pages>

In the code above, by specifying include_custom_fields='1' we make the cms:nested_pages fetch the editable region's data as well. We the use the value of 'page_class' region as
<li class="<cms:show page_class />">..

Hope it helps.
Yes it did, thank you!
5 posts Page 1 of 1