Forum for discussing general topics related to Couch.
16 posts Page 2 of 2
The way things are structured, following your post with gallery code, are ok. What I tried to say in my previous post is:
1. I created folders (PARENT FOLDERS) for each service name: Indoor decorations, Outdoor decorations, Car decorations, ....
2. I created folders (CHILD FOLDERS) inside the folders above:
Indoor decorations (Parent)
|___ 2010 (Child)
|___ 2011 (Child)
|___ 2012 (Child)
|___ 2013 (Child)

Outdoor decorations (Parent)
|___ 2010 (Child)
|___ 2011 (Child)
|___ 2012 (Child)
|___ 2013 (Child)

3. Issue nr. 1 - The child folders appears also in home view, I need only parent folders to be displayed.

Issue nr. 2 - In folder view all images from a parent folder are displayed regardless the child folder they are belonging to. That's ok, I like that. But I want to place a combobox at the top of the gallery from where visitors can select the desired child folder (year), to display only the images belonging to that child folder. This is the filtering I would like to do.

In Couch documentation I have found something in Core concepts - Folders - Parents and Children section, but I really don't know how to put things together to get the things working.
1. Use depth='1' with the cms:folders tag to list only the root folders.

2. While it would be possible to implement, I don't suggest you perform the filtering with year child folders. The publish date for each cloned page is already saved and available for us to use.

There are definitely other approaches, including using the archive view, but this is the one I would personally use:

To indicate which year we want to display, at the end of the URL we will append a querystring:
yoursite.com/portfolio/indoor-decorations/?year=2013

Place the following code anywhere near the top of the page. It will retrieve the querystring value and store it in a variable. We also keep track of what the next year is.
Code: Select all
<cms:if "<cms:gpc 'year' method='get'/>">
   <cms:set year = "<cms:gpc 'year' method='get'/>"/>
   <cms:set year_next = "<cms:add year '1'/>"/>
<cms:else/>
   <cms:set year = ''/>
   <cms:set year_next = ''/>
</cms:if>

In any of the cms:pages tags we can now filter with the above variables:
Code: Select all
<cms:pages start_on=year stop_before=year_next>
   ...
</cms:pages>

We can create the dropdown to control this filtering like so:
Code: Select all
<form method="get" action="">
   <select name="year" onchange="this.form.submit();">
      <option value="">-- Choose Year --</option>
      <cms:archives type='yearly'>
         <cms:set archive_year = "<cms:date k_archive_date format='Y'/>"/>
         <option value="<cms:show archive_year/>"<cms:if archive_year == year> selected="true"</cms:if>><cms:show archive_year/></option>
      </cms:archives>
   </select>
   <noscript>
      <input type="submit" value="Filter">
   </noscript>
</form>

Let me know how this works out. ;)
The reason why I would like to use child folders instead publish date is that in fact portfolio pictures must be uploaded since year 2006. Having hundreds of photo to upload, is not easy to change publish date for each of them to obtain the correct categorization by year. But using child folders makes it no difficult at all.
How about creating a JavaScript bookmarklet to more quickly change the year?
Code: Select all
javascript:document.getElementById("f_k_year").value="2006";void(0);
@cheesypoof, I think Atilla's concern is valid. It would be very difficult to manually tweak the publish dates of all the items.

Since the hierarchical folder structure is already in place, it shouldn't be difficult to create a dropdown of folder names (showing the second-level 'years' folders). Selecting any of which will invoke the folder-view for the selected folder showing only images belonging to it.

Following is a variation of the mentioned technique used in viewtopic.php?f=2&t=7387

@Atilla, please add the following content enclosed within the <cms:if k_is_folder> block in your existing <cms:if k_is_folder> code
Code: Select all
<cms:if k_is_folder>

    <cms:set current_folder_name = k_folder_name />
    <cms:set current_root_folder = '' />
   
    <cms:parentfolders folder=current_folder_name >
        <cms:if current_root_folder=''>
            <cms:set current_root_folder = k_folder_name 'global' />
        </cms:if>
    </cms:parentfolders>

    <form method="get" action="">
       <select name="date" onchange="if (this.options[this.options.selectedIndex].getAttribute('data-url') != '#') window.location.href = this.options[this.options.selectedIndex].getAttribute('data-url');">
          <option data-url="#" value="">-- Choose Year --</option>
          <cms:folders childof=current_root_folder depth='1'>
             <option data-url="<cms:show k_folder_link/>" value="<cms:show k_folder_name/>"<cms:if k_folder_name == current_folder_name> selected="true"</cms:if>><cms:show k_folder_title/></option>
          </cms:folders>
       </select>
       <noscript>
          <input type="submit" value="Filter">
       </noscript>
    </form>

   .... Your existing code here ....

</cms:if>

The only new thing here is that whether we are within Indoor decorations (Parent) folder or one of its 201x (Child) folder, in the dropdown we always display only the children of the parent folder. This we have done using the cms:parentfolders tag to find the top-level parent folder of the current folder.

Hope this helps. Please let us know.
Thank you KK, that worked! Finally my template is fully finished and images are uploaded.
I haven't worked till this moment with gallery, but as you know, it makes our life so much easier (comparing repeatables, with which I started).
Thank you once again for the fantastic support!

Attila
16 posts Page 2 of 2
cron