Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
I am working more on the couchcms demo site and had a thought that it would be good to be able to automatically add clonable pages to the menu

I have the index.php as a nested page and created a page.php as a clonable to create pages

I found coding from a post looking to do the same and got a checkbox added to page.php which adds the checkbox on the admin panel when creating or editing a existing clonable page. I have a snippet called menu.html

My clonable page.php coding is below that adds the checkbox to the admin panel when creating a new page or editing a existing page

Code: Select all
<cms:editable name='my_show_in_menu' label='Show in menu' desc='tick if this page appears in the menu' opt_values='Yes=1' type='checkbox' order='200'
/>


My menu html snippet coding is below

Code: Select all
<ul class="navbar-nav ml-auto">
  <cms:nested_pages masterpage='index.php'>
    <li class="nav-item">
      <a class="nav-link" href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a>
    </li>
  </cms:nested_pages>
</ul>


The coding I found by KK is: viewtopic.php?f=4&t=9885#p22663

When I did the coding below in menu.html, no menu was displayed

Code: Select all
<cms:if k_element_start ><li>
    <a href="<cms:show k_menu_link />"><cms:show k_menu_title /></a>
    <cms:if k_is_pointer && (k_nestedpage_name='first-page') >
        <ul>
        <cms:pages masterpage="<cms:show k_nestedpage_name />.php" custom_field="my_show_in_menu=1">
            <li><a href="<cms:show k_page_link />"><cms:show k_page_name /></a></li>
        </cms:pages>   
        </ul>
    </cms:if>
</cms:if>


I was bit unsure how to amend the menu.html snippet to include both nested page in the menu as well as the clonable page using the checkbox field I added in
UPDATE: I have been playing around with the menu.html snippet file and got closer as now I got the links showing when if the checkbox is checked when creating or editing a clonable page template from the admin side, the only issue I got now is they show after the nested pages but I need them to show in between the nested page, my updated menu.html file is below

Code: Select all
<ul class="navbar-nav ml-auto">
  <cms:nested_pages masterpage='index.php'>
    <li class="nav-item">
      <a class="nav-link" href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a>
    </li>
  </cms:nested_pages>
  <cms:pages masterpage='page.php'custom_field="my_show_in_menu=1">
  <li class="nav-item">
  <a class="nav-link" href="<cms:show k_page_link />"><cms:show k_page_title /></a>
  </li>
</cms:pages>
</ul>


I'll keep having a play around with the file or just had a thought, I wonder if I could add in a order field and add that in somehow to the menu.html snippet file or maybe use the if and else couchcms tags
2 posts Page 1 of 1