Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
I'm building a dyanamic folders photo gallery. I've been using the below code successfully for the embeded list view to see only what each folder has:

Code: Select all
<cms:pages folder=k_folder_name include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>


My gallery has a mini thumbnail broswer in the page view that is using the same code - but it's not behaving correctly. It only shows images from the root folder. It won't display the correct folder contents. How can I add some kind of conditional code that figures out what folder the current page view resides in? I've also had issues with looping threw just the folder content. It loops threw the entire root and sub folder content. My navigation is at the page level, not list view level. Thanks for any insight!
Hi,

Could you please post in some screenshots (mockup also would do) showing the kind of functionality you desire?
If you could also post in the current code you are using, it'd be helpful.

Thanks
OK, I assume this question also pertains to your another thread - viewtopic.php?f=2&t=7868

I'll try and answer the queries you had -
My gallery has a mini thumbnail broswer in the page view that is using the same code - but it's not behaving correctly.

The page-view is the key to the problem.
In a page-view the 'k_folder_name' variable is not available (it is only in the folder-view) and so the blank 'folder' parameter is ignored and effectively your code becomes -
Code: Select all
<cms:pages include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>

As you can see, we are listing all the pages (including root) and the include_subfolders='0' is causing the sub-folders to be skipped leaving us with only the pages directly in root.
It only shows images from the root folder. It won't display the correct folder contents.
The point above explained this.

How can I add some kind of conditional code that figures out what folder the current page view resides in?

If the page being viewed resides in a folder, Couch will provide you with the full details as variables e.g. k_page_foldername, k_page_foldertitle etc.
You can find details at http://www.couchcms.com/docs/concepts/v ... views.html

Or, better still, simply place a <cms:dump /> tag in your view and you'll see a list of all the variables available with their values.

The conditional could now become -
Code: Select all
<cms:if k_page_foldername='some_folder_name'>
   .. do something..
</cms:if>

I've also had issues with looping threw just the folder content. It loops threw the entire root and sub folder content.

I think you must be missing setting the include_subfolders='0' parameter - with this set only contents immediately within a folder (or root) are listed, as seen above.

Hope this helps. Please let me know if something is still unclear.
Thanks.
Thanks for the reply! Yes, it's the same page as the other thread:

http://www.chrisnuzzaco.com/storage/new ... yout2.html
http://www.chrisnuzzaco.com/storage/new ... llery.html

I got this working successfully, but there's an issue - its hardcoded.

Code: Select all
<cms:if k_page_foldername='two'>

<cms:pages folder='two'  include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>

<cms:else />

<cms:pages include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>

</cms:if>


How do you set the folder name dynamically?
I've been trying this, but it never works.

Code: Select all
<cms:if k_page_foldername='<cms:show k_page_foldername/>'>
<cms:pages folder='<cms:show k_page_foldername/>'  include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>

<cms:else />

<cms:pages include_subfolders='0' >
   <a href="<cms:show k_page_link/>" class="transition">
      <img src="<cms:show gg_thumb/>" alt="<cms:show image_alt/>"/>
   </a>
</cms:pages>

</cms:if>
The right syntax would be to use double-quotes
Code: Select all
<cms:pages folder="<cms:show k_page_foldername/>"  include_subfolders='0' >

or simply the variable directly e.g.
Code: Select all
<cms:pages folder=k_page_foldername include_subfolders='0' >

That said, I don't think the code you are using will do what you expect it to do.

Can you please forget the code for a moment and let me know in plain English the logic that you are trying to implement? e.g.
1. While viewing a page, I want to show all the other pages residing in the same folder as the page
2. While viewing the home-view, I want to display a list of all the folders
etc.

Thanks.
:D It worked!

I'm about 95% where I want to be with the code and admin setup.

Basic goals:

When you enter each gallery - the list view shows only whats in the folder (successfully implemented).

When you navigate the gallery page links, you only loop threw the folder content (successfully implemented).

Each gallery page has a popout thumbnail navigator - it only shows images from the current gallery pages folder (successfully implemented).

My last remaining issue is building the menu structure dynamically. I want a list of folders to appear in the photography menu div - structured as topic -> then actual links below. The topic is currently a folder filled with sub folders. So basically I have root - topic folders -> gallery folders with images. In a nutshell, I would output left floated unordered lists. None of the topics folders would be linkable, just the sub folders.

Thanks again!
I think there is nothing in the scenario that cannot be handled with cms:folders and cms:pages tags.

Did you take a look at http://www.couchcms.com/docs/concepts/u ... lders.html ?

Do let us know if get stuck at anything.

Thanks.
This code appears to be produing the kind of html I need, but I can't figure out how to prevent the topmost folder from being linkable, it just makes everything a link regardless of tree position. I only need sub folders to be active links.

Code: Select all
<cms:folders masterpage='gallery.php'  hierarchical='1' extended_info='1'>
    <cms:if k_level_start ><UL></cms:if>
    <cms:if k_element_start ><LI>
        <a href="<cms:show k_folder_link/>"><cms:show k_folder_title /></a>
    </cms:if>
    <cms:if k_element_end ></LI></cms:if>
    <cms:if k_level_end ></UL></cms:if>
</cms:folders>
Couch makes available as variables all the info about the folders it iterates through.
If you were to place a <cms:dump /> tag just below where you output the link i.e. like this -
Code: Select all
<cms:folders masterpage='gallery.php'  hierarchical='1' extended_info='1'>
    <cms:if k_level_start ><UL></cms:if>
    <cms:if k_element_start ><LI>
        <a href="<cms:show k_folder_link/>"><cms:show k_folder_title /></a>
        <cms:dump />
    </cms:if>
    <cms:if k_element_end ></LI></cms:if>
    <cms:if k_level_end ></UL></cms:if>
</cms:folders>

- you'll see all these variables. One of them is 'k_level' that shows the level of the folder (0 for top, 1 for the first child etc.).
We can now use this variable to output/hide the link as you want.

The code you need now becomes -
Code: Select all
<cms:folders masterpage='gallery.php'  hierarchical='1' extended_info='1'>
    <cms:if k_level_start ><UL></cms:if>
    <cms:if k_element_start ><LI>
        <cms:if k_level gt '0' >
            <a href="<cms:show k_folder_link/>"><cms:show k_folder_title /></a>
        <cms:else />
            <cms:show k_folder_title />
        </cms:if>
    </cms:if>
    <cms:if k_element_end ></LI></cms:if>
    <cms:if k_level_end ></UL></cms:if>
</cms:folders>

Hope this helps.
10 posts Page 1 of 1