by
KK » Thu Oct 04, 2018 11:42 am
I can see two problems with your code -
1. You are using 'single quotes' while trying to set 'opt_values' param through Couch tags. One needs to use 'double quotes' for the enclosed Couch tags to be executed.
2. If you study the sample filtered search I mentioned, you'll find that the form lies just above the <cms:pages> block. Once it is successfully submitted, the form uses the submitted values to set some global variables that are used by the <cms:pages> block that follows. Your code is not doing that.
Following is some working code that rectifies those issues. It is filtering by folder and year. Please notice how the k_success block uses the submitted folder and year to set the global variables 'my_folder', 'my_start_date' and 'my_stop_date' eventually used in <cms:pages> listing that follows it.
- Code: Select all
<cms:if k_is_list>
<cms:form name="quicksearch" id="quicksearch" anchor='0'>
<cms:if k_success >
<cms:if frm_my_folder!='-' >
<cms:set my_folder = frm_my_folder scope='global'/>
</cms:if>
<cms:if frm_my_date!='-' >
<cms:set my_start_date = "<cms:show frm_my_date />-01-01" scope='global'/>
<cms:set my_stop_date = "<cms:add frm_my_date '1' />-01-01" scope='global'/>
</cms:if>
<!-- debug info. Remove after testing -->
<cms:show my_folder /><br>
<cms:show my_start_date /><br>
<cms:show my_stop_date /><br>
</cms:if>
<div>
<label>Folder</label>
<cms:input
type='dropdown'
opt_values="Filter by Client=- | <cms:folders masterpage='project.php'><cms:show k_folder_title /> = <cms:show k_folder_name /> |</cms:folders>"
opt_selected='-'
name='my_folder' />
</div>
<div>
<label>Year</label>
<cms:input
type='dropdown'
opt_values="Filter by Year=- | <cms:archives masterpage='project.php' type='yearly'><cms:date k_archive_date format='Y' /> | </cms:archives>"
opt_selected='-'
name='my_date' />
</div>
<div class="buttonset">
<cms:input type="submit" class="fbsubmitbtn" value="Start Searching!" name="submit"/>
</div>
</cms:form>
<cms:pages masterpage='project.php' paginate='1' limit='9' folder=my_folder start_on=my_start_date stop_before=my_stop_date>
<h2><cms:show k_page_title /></h2>
....
<cms:no_results>
No projects found
</cms:no_results>
</cms:pages>
</cms:if>
Hope this helps.