by
KK » Wed May 29, 2013 9:08 pm
Hi,
Let us assume you have two folders named 'folder_one' and 'folder_two'.
The following snippet then should create a single group of images for fancybox
where all images will belong to folder_one (please notice that the 'folder' parameter is set to 'folder_one' i.e. the name of the folder)
- Code: Select all
<cms:pages masterpage="gallery.php" include_subfolders='0'
folder='folder_one' >
<a class="fancybox<cms:if k_count gt '1'> hidden</cms:if>"
href="<cms:show gg_image />"
data-fancybox-group="<cms:show k_page_foldername />"
title="<cms:show k_page_title />">
<img src="<cms:show gg_thumb />" alt="" /></a>
</cms:pages>
To create a second group of images belonging to the second folder, we'll have to
repeat the above snippet this time specifying the name of the second folder e.g.
- Code: Select all
<cms:pages masterpage="gallery.php" include_subfolders='0'
folder='folder_two' >
..
</cms:pages>
Instead of repeating almost the same code multiple times, we can make use of the cms:folders tag (
http://www.couchcms.com/docs/tags-refer ... lders.html) to enumerate all the available folders and then feed the names to the cms:pages tag.
- Code: Select all
<cms:folders masterpage="gallery.php">
<cms:pages masterpage="gallery.php" include_subfolders='0'
folder=k_folder_name >
<a class="fancybox<cms:if k_count gt '1'> hidden</cms:if>"
href="<cms:show gg_image />"
data-fancybox-group="<cms:show k_page_foldername />"
title="<cms:show k_page_title />">
<img src="<cms:show gg_thumb />" alt="" /></a>
</cms:pages>
</cms:folders>
Please notice in the snippet above that our original code is now nested within cms:folders
tag which loops through the folders and sets the
k_folder_name variable to the name of the folder being iterated.
We use this
k_folder_name variable to specify the 'folder' parameter of the cms:pages tag instead of hard-coding the names as we did before (notice that there are no enclosing quotes around k_folder_name which means it is a variable).
Please try these snippets and let me know if it is close to what you desire.
Thanks.