Multiple values

There will be times when you need to build a query that searches the CMS for more than one value i.e. News Item region (Africa, Europe etc)

This example gets a list of values from a multiple select field on a form either via the methods get (querystring) or post.

  1. #if($request.getParameterValues('regions'))  
  2.   
  3.     #foreach ($regions in $request.getParameterValues('regions'))  
  4.         #if ($query_regions)  
  5.             #set ($query_regions = "$!{query_regions} YOURSTRUCTURENAME.regions:*${regions}*")  
  6.         #else  
  7.             #set ($query_regions = "YOURSTRUCTURENAME.regions:*${regions}*")  
  8.         #end  
  9.     #end  
  10.   
  11.     #if ($query_regions)  
  12.         #set ($query_regions = "+(${query_regions})")  
  13.     #end  
  14.   
  15.     #set($query = "+structureName:YOURSTRUCTURENAME $!{query_regions}")  
  16.   
  17. #end  
comments powered by Disqus