Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
EDIT#1: Added code

Greeting to all and a very happy friendships day to all my CouchCMS friends!!!

@KK sir and @All,

I have a couch cart template with dynamic folders active. I want to generate a navigation menu for the folders and sub-folders to be displayed on the site globally (in all views) using this template. I am using bootstrap 3 navbar for the navigation menu.

My dynamic folders has only two levels, viz:
1. the main folder
2. the sub folder

The folder structure is as follows:
- MUGS
- - TRAVEL
- - SPIRITUAL
- - NATURE
- - GREETING
- LEATHER
- - WOMAN
- - TRAVEL
- - MEN
- - ACCESSORIES
- DIARY
- - SEEDED
- - NON SEEDED
- COPPER
- - TANK
- - JUG
- - GLASS
- - BOTTLE


What I am trying to achieve is that:
1. The menu needs to show the above quoted structure on all pages throughout the site
2. When an item is clicked it needs to go to the respective view,
e.g.: a. if mugs is clicked, it needs to display all the pages in the mugs folder
b. if travel is clicked, it needs to display only the pages under travel.

My current code is as follows, but it is not giving the desired result:
Code: Select all
<cms:folders masterpage="product.php" hierarchical="1" order="desc" depth="1">
    <li class="dropdown">
        <a href="<cms:show k_folder_link />" class="dropdown-toggle" data-toggle="dropdown"><cms:show k_folder_title /> <b class="caret"></b>
        </a>
        <ul class="dropdown-menu" role="menu">
       <cms:folders masterpage="product.php"  root=k_folder_name >
      <li>
          <a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a>
                </li>
                <cms:if "<cms:not k_last_child />" >
                <li role="separator" class="divider"></li>
                </cms:if>
            </cms:folders>
        </ul>
    </li>
</cms:folders>


How can this be achieved?
Thanks in advance.

Regards,
GenXCoders
Image
where innovation meets technology
Hi,

I think what you are asking for is pretty much the standard way things work in Couch -
a. Use <cms:folders> with hierarchical='1' to create the menu (https://docs.couchcms.com/concepts/using-folders.html)
b. In the folder-view reached through the menu above, use <cms:pages> (https://docs.couchcms.com/concepts/listing-pages.html) -
Code: Select all
<cms:if k_is_folder >
    <cms:pages folder=k_folder_name include_subfolders='1' >
        <!-- All the variables of each page in this folder are available here -->
    </cms:pages>
</cms:if>

So, what is it that does not seem to work for you?
Please let me know.
@KK Sir,

As always, I am stuck on folders concept. :oops:

I have put the site online at https://www.thedashami.com/demo/.

If you navigate to any product category (folder) the display remains the same in the navigation but on the product list page the sub folders are not displayed.

Code for the same is:
Code: Select all
<cms:folders masterpage="product.php" hierarchical="1" depth="2" childof=k_folder_name >
    <li>
        <a href="<cms:show k_folder_link />" style="color: #212121;">
            <cms:show k_folder_title /> (<cms:show k_folder_totalpagecount />)
        </a>
    </li>
</cms:folders>


Regards,
GenXCoders
Image
where innovation meets technology
I think your problem is the way sub-folders are displayed in the sidebar.

What you probably want to have is this -
if 'MUGS' (a top-level folder) is clicked, the sidebar shows its children i.e.
- - TRAVEL
- - SPIRITUAL
- - NATURE
- - GREETING

and when a child e.g. 'NATURE' is clicked, the sidebar still shows the same menu as above (with perhaps NATURE highlighted).

The code that you posted last shows the children of the current folder being visited. So when 'MUGS' is clicked, it correctly shows the menu shown above. However, when 'NATURE' is clicked, the menu disappears because the current folder 'NATURE' does not have any children. Get that point?

The solution is to always show the children of the top-level parent (i.e. MUGS) irrespective of which folder in the hierarchy we are visiting.

Following amendment to your code should do that -
Code: Select all
<!-- if we are in a folder view -->
<cms:if k_is_folder >

    <!-- get the top level parent folder of the current folder -->
    <cms:parentfolders folder=k_folder_name >
        <cms:if k_level eq '0'>
            <cms:set my_root_folder = k_folder_name scope='global' />
        </cms:if>
    </cms:parentfolders>
   
    <!-- and show the children of that parent folder -->
    <cms:folders hierarchical="1" depth="2" childof=my_root_folder >
        <li>
            <a href="<cms:show k_folder_link />" style="color: #212121;">
                <cms:show k_folder_title /> (<cms:show k_folder_totalpagecount />)
            </a>
        </li>
    </cms:folders>

</cms:if>

Hope this helps.
@KK Sir,

Yes that works perfectly.
Thanks a lot sir.

I have never used <cms:parentfolders> tag before this.

Regards,
GenXCoders
Image
where innovation meets technology
5 posts Page 1 of 1
cron