Forum for discussing general topics related to Couch.
6 posts Page 1 of 1
I'm trying out the Dynamic Folders feature and I'm really pleasently surprised about how easy it is to work with it in the Admin.

I have a problem on the front-end. The matter is, I'd like to be able to list contents of a folder in a way that the list shows only the direct (single level below) children of that folder (parent).

In other words, it would be structured something like this (subfolders are marked with all caps):

- SUBFOLDER 1
- Page 1
- Page 2
- Page 3
- SUBFOLDER 2
- Page 4
...

So basically, in order to see what pages and/or folders are contained within a subfolder, you'd have to click it and would then be presented with the list of its contents.

Right now, in my case, this list looks like this (pages which are direct children of the root foolder are designated with 0.X):

- Page 1.1 (Child of the SUBFOLDER 1)
- Page 0.1
- Page 0.2
- Page 0.3
- Page 2.1 (Child of the SUBFOLDER 2)
- Page 2.2 (Child of the SUBFOLDER 2)
- Page 0.4
...

The code I'm using to generate this list is
Code: Select all
<cms:pages masterpage='demos.php' folder='folder' paginate='1' limit='10'>


Is there a way to refine this list so that it shows only the items of the same "depth" or "level" within a folder?

Thanks in advance.
Hi Davor,

We can turn-off the include_subfolders parameter (which is on by default) to make cms:pages fetch only immediate pages of a folder (or the root) e.g. the following code should do it -
<cms:pages masterpage='demos.php' folder='folder' include_subfolders='0' paginate='1' limit='10'>

Does this help?
Hi KK, thanks for th reply. This seems to simply not list the subfolders at all. All I get in the list now are pages which aren't in any subfolders.

What I'd like to achieve is the standard "file explorer" behaviour, so to speak. When I open a folder, I'd like to see listed both links to next level subfolders, and pages not in any subfolders whatsoever. Is that doable?
Yes, of course it is possible.

You wish to list both child folders as well as pages so we'll have to use two different Couch tags - cms:folders and cms:pages.

Following is a sample snippet that should demonstrate how. The list_view part is where we show child folders and child pages.
Code: Select all
<cms:if k_is_list>

    <cms:if k_is_folder >
        <h2>Folder: <cms:show k_folder_title /></h2>
    </cms:if>
   
    <!-- list immediate child folders of this folder (or root) -->
    <h2>Sub folders</h2>
    <ul>
        <cms:folders childof=k_folder_name hierarchical='1' depth='1'>
            <li><a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a></li>
        </cms:folders>
    </ul>       

    <!-- list immediate pages of this folder -->
    <h2>Pages</h2>
    <cms:pages folder=k_folder_name include_subfolders='0' >
         <h3><cms:show k_page_title /></h3>
    </cms:pages>
   
<cms:else />
   
    <!-- show page data -->
    <h2><cms:show k_page_title /></h2>
    .. other data ..
   
</cms:if>

Hope this helps.
Please let me know.

Thanks
Sadly, not producing any results whatsoever. Nevermind, we'll have to live without that. Thanks for the help anyway.
Hey Davor,

Living without that is not an option, my friend :)

The code I posted is tried and tested. Please try this -
create a new clonable template (say named 'test.php') with dynamic folders. Create some folders in an hierarchy and a few dummy pages.

Paste into it the very code I posted and try it out. There is absolutely no reason why it won't work.

That said, can you please PM me your own template (with associated snippets required for it to work)?
Also, maybe I am not getting exactly how you are trying to implement the folder tree.
Please take some time to PM me a few rough image mockups of how the finished page will look like with the functioning tree within it.

Finally, please don't give up so easily :) A little patience and we'll definitely get there.

Thanks
6 posts Page 1 of 1
cron