Forum for discussing general topics related to Couch.
15 posts Page 1 of 2
Ok, I have a new problem.

When I go to my photography-section I would like to see a list of categories like models or architecture etc. and when I click on one of them I would like to be referred to a site where I can see the models and their pictures (sub-categories). I'll try to show it:

> home
> photography
-models
- candy []
- chocolate []
-architecture
- hobbit-building []

([] means pictures)

I want to do this with folders but I'm not able to show up the folders "models" and "architecture" and make them linkeable to the sub-categories/folders with the pictures.
KK wrote: This seems to be a staple usecase involving folder-view and listing in it the pages contained within the folder -
http://docs.couchcms.com/concepts/views.html
http://docs.couchcms.com/concepts/listing-pages.html

The folders can be listed (with their links) using cms:folders tag (http://docs.couchcms.com/concepts/using-folders.html).

If your usecase involves something different, please post some mockups (or wireframes) showing how the data should be displayed and we can discuss ways of implementing it.

Also, this seems to be unrelated to the original topic of this thread.
May I request you to please create a new thread for this discussion?

Thanks.


I'm going to try this soon. If I can't get it to work, I'll post a mockup
Ok, I tried it but I have absolutely no idea how to solve it. Here is a little mockup. I'll hope you can understand it :D

Attachments

I think you'll find the following sample code useful (I've commented it pretty liberally) -
Code: Select all
<!-- home-view e.g. http://www.yoursite.com/photography/ -->
<cms:if k_is_home>

    <!-- show only the top-level folders (e.g. models & architecture)-->
    <cms:folders orderby='weight' order='asc' depth='1' >
   
        <!-- clicking the link below will lead to the folder-view -->
        <a href="<cms:show k_folder_link />"><h2><cms:show k_folder_title /></h2></a>
        <cms:show k_folder_desc />
       
        <hr />
       
    </cms:folders>

</cms:if>

<!-- folder-view e.g. http://www.yoursite.com/photography/models/ -->
<cms:if k_is_folder>

    <!--
        this is a folder-view so we are inside a folder (e.g. 'models') at this point.
        Show the immediate child folders of this folder
    -->
    <cms:folders childof=k_folder_name orderby='weight' order='asc' depth='1' >
   
        <!-- we are now within the child folders e.g. 'chocolate' or 'candy' -->
        <h2><cms:show k_folder_title /></h2>
        <cms:show k_folder_desc />
       
        <!-- also show the cloned pages within this child folder -->
        <cms:pages folder=k_folder_name>
            <a href=""><cms:show k_page_title /></a>
            .. all editable regions of the page available e.g. any image ..
        </cms:pages>
       
        <hr />
       
    </cms:folders>

</cms:if>

Please notice how we are handling the 'home_view' and the 'folder_view'.
Hope it helps.
KK wrote: I think you'll find the following sample code useful (I've commented it pretty liberally) -
Code: Select all
<!-- home-view e.g. http://www.yoursite.com/photography/ -->
<cms:if k_is_home>

    <!-- show only the top-level folders (e.g. models & architecture)-->
    <cms:folders orderby='weight' order='asc' depth='1' >
   
        <!-- clicking the link below will lead to the folder-view -->
        <a href="#"><h2><cms:show k_folder_title /></h2></a>
        <cms:show k_folder_desc />
       
        <hr />
       
    </cms:folders>

</cms:if>

<!-- folder-view e.g. http://www.yoursite.com/photography/models/ -->
<cms:if k_is_folder>

    <!--
        this is a folder-view so we are inside a folder (e.g. 'models') at this point.
        Show the immediate child folders of this folder
    -->
    <cms:folders childof=k_folder_name orderby='weight' order='asc' depth='1' >
   
        <!-- we are now within the child folders e.g. 'chocolate' or 'candy' -->
        <h2><cms:show k_folder_title /></h2>
        <cms:show k_folder_desc />
       
        <!-- also show the cloned pages within this child folder -->
        <cms:pages folder=k_folder_name>
            <a href=""><cms:show k_page_title /></a>
            .. all editable regions of the page available e.g. any image ..
        </cms:pages>
       
        <hr />
       
    </cms:folders>

</cms:if>

Please notice how we are handling the 'home_view' and the 'folder_view'.
Hope it helps.


NICE! It works :) I just had to change the href-link to <cms:show k_folder_link /> to make it working. Thanks a lot for your help. :)

But I have a last question! Is it possible to bring up a popup window by clicking on a gallery picture which will have the size of that image?
KK wrote: I think you'll find the following sample code useful (I've commented it pretty liberally) -
Code: Select all
<!-- home-view e.g. http://www.yoursite.com/photography/ -->
<cms:if k_is_home>

    <!-- show only the top-level folders (e.g. models & architecture)-->
    <cms:folders orderby='weight' order='asc' depth='1' >
   
        <!-- clicking the link below will lead to the folder-view -->
        <a href="<cms:show k_folder_link />"><h2><cms:show k_folder_title /></h2></a>
        <cms:show k_folder_desc />
       
        <hr />
       
    </cms:folders>

</cms:if>

<!-- folder-view e.g. http://www.yoursite.com/photography/models/ -->
<cms:if k_is_folder>

    <!--
        this is a folder-view so we are inside a folder (e.g. 'models') at this point.
        Show the immediate child folders of this folder
    -->
    <cms:folders childof=k_folder_name orderby='weight' order='asc' depth='1' >
   
        <!-- we are now within the child folders e.g. 'chocolate' or 'candy' -->
        <h2><cms:show k_folder_title /></h2>
        <cms:show k_folder_desc />
       
        <!-- also show the cloned pages within this child folder -->
        <cms:pages folder=k_folder_name>
            <a href=""><cms:show k_page_title /></a>
            .. all editable regions of the page available e.g. any image ..
        </cms:pages>
       
        <hr />
       
    </cms:folders>

</cms:if>

Please notice how we are handling the 'home_view' and the 'folder_view'.
Hope it helps.


Great stuff, KK!
My use case is a little bit more complex, as I don't have a fixed folder depth for my pages, some pages are belonging to a child-folder, others to a child-child-folder, or even child-child-child-folder. I'm wondering if it is possible to show pages only for the last depth folder. It would be really nice if clicking the last depth folder will show somehow the contained pages.
Any thought about this?

Thanks.
I enjoy tricky things so couldn't keep silence.

Getting the last child folder is not an easy task, it requires a LOT of messing because we don't have folder creation date, don't have total folder count out of the box etc, etc, etc. BUT!

If you assign a weight to last child manually to indicate deepest folders (you are creating folders manually, anyways), this can help magically.
Let's say all deepest child folders have a weight > 100. Then simple check helps here:
Code: Select all
<cms:pages...
<cms:if k_page_folderweight gt '100' >
.. this page belongs to the deepest folder in hierarchy ..
</cms:if>
</cms:pages>

:lol:
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
trendoman wrote: I enjoy tricky things so couldn't keep silence.

Getting the last child folder is not an easy task, it requires a LOT of messing because we don't have folder creation date, don't have total folder count out of the box etc, etc, etc. BUT!

If you assign a weight to last child manually to indicate deepest folders (you are creating folders manually, anyways), this can help magically.
Let's say all deepest child folders have a weight > 100. Then simple check helps here:
Code: Select all
<cms:pages...
<cms:if k_page_folderweight gt '100' >
.. this page belongs to the deepest folder in hierarchy ..
</cms:if>
</cms:pages>

:lol:


Thanks for the tip trendoman!
Sounds great, but unfortunately, it's not working for me. Do I do something wrong? Here is my code:
Code: Select all
<cms:if k_is_folder>
           <div>
              <ul>
                 <cms:folders childof=k_folder_name orderby='weight' order='asc' depth='1' >
                  <li><a href="<cms:show k_folder_link/>"><img src="<cms:show k_folder_image />" alt="<cms:show k_folder_title/>" title="<cms:show k_folder_title/>" border="0" /><div><i class="fa fa-link"></i></div></a><h2><a href="<cms:show k_folder_link/>"><cms:show k_folder_title/></a></h2></li>
                   <cms:pages folder=k_folder_name>
                        <cms:if k_page_folderweight gt '100' >
                            <a href="<cms:show k_page_link />"><cms:show k_page_title /></a>
                        </cms:if>
                    </cms:pages>
                 </cms:folders>
               </ul>
           </div>
        </cms:if>
What happens in my case: the pages belonging to deepest folder (weight=101) are shown in each child folder view, except the deepest one.

Thanks.
@trendoman, you stated -
Getting the last child folder is not an easy task, it requires a LOT of messing because we don't have folder creation date, don't have total folder count out of the box etc, etc, etc.

I don't think it should be too difficult. In a folder_view, every folder sets the following variables
Code: Select all
k_folder_immediate_children
k_folder_totalchildren

Those two refer to the number of child folders below the current folder.
For a folder that is the last in hierarchy, obviously both the values would be '0'.

I think that info could be used to target the last folder.
Your thoughts?
KK, aren't they for pages? I thought only number of pages is listed through these system variables. With those, it should be as easy as taking a candy from a child. :lol:
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
15 posts Page 1 of 2