Luke Barton
|
Sunday 20 November 2005 2:59:09 pm
I've searched the forums for a few hours, but I cannot get my search filters to work. Here's my set up:
1. I only wish to search under 1 node (node_id = 60). 2. I only wish to search certain content class (class_id = 23). I've tried variations of the following code, but I still get results of mixed class and from other node trees.
{section show=$use_template_search}
{set page_limit=10}
{set search=fetch(content,search,
hash('text',$search_text,
'subtree_array',array(60),
'class_id',array(23),
'offset',$view_parameters.offset,
'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
{set search_data=$search} {/section} or
{section show=$use_template_search}
{set page_limit=10}
{set search=fetch(content,search,
hash('text',$search_text,
'subtree_array',60,
'class_id',23,
'offset',$view_parameters.offset,
'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
{set search_data=$search} {/section} or even
{section show=$use_template_search}
{set page_limit=10}
{set search_subtree_array=60}
{set class_id=23}
{set search=fetch(content,search,
hash('text',$search_text,
'subtree_array',$search_subtree_array,
'class_id',$class_id,
'offset',$view_parameters.offset,
'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
{set search_data=$search} {/section} or
{section show=$use_template_search}
{set page_limit=10}
{set search_subtree_array=array(60)}
{set class_id=array(23)}
{set search=fetch(content,search,
hash('text',$search_text,
'subtree_array',$search_subtree_array,
'class_id',$class_id,
'offset',$view_parameters.offset,
'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
{set search_data=$search} {/section} I feel like I'm missing something obvious. I'm using ez 3.6.4. Thanks in advance for your help. -Luke
|
Ćukasz Serwatka
|
Sunday 20 November 2005 11:13:34 pm
Hi Luke, You can create your filter using advancedsearch from and hidden fields:
<form action={"/content/advancedsearch/"|ezurl} method="get">
<input class="searchbox" type="text" size="8" name="SearchText" id="Search" value="" />
<input class="searchbutton" name="SearchButton" type="submit" value="Search" />
<input type="hidden" name="SubTreeArray[]" value="60" />
<input type="hidden" name="SearchContentClassID" value="23" />
</form>
Turn on debug output to check possible errors. Check is attributes of class 23 are searchable. Try with:
{let search_result=array()
search_count=array()
stop_word_array=array()
search=array()
page_limit=10
{*read get variable*}
search_text=ezhttp('SearchText', 'get')}
{set search=fetch(content,search, hash('text',$search_text,
'subtree_array',array(60),
'class_id',array(23),
'offset',$view_parameters.offset,
'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
{section loop=$search_result}
{$item.name}
{/section}
{/let}
Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog
|
Luke Barton
|
Wednesday 23 November 2005 12:15:22 pm
Lukasz, Thanks for much for pointing me in the right direction. My simple search form now filters on node_tree and class_id:
{let search_result=array()
search_count=array()
stop_word_array=array()
search=array()
page_limit=10
search_text=ezhttp('SearchText','get')|wash}
{set search=fetch(content,search, hash('text',$search_text, 'subtree_array',array(61, 169, 161), 'class_id',array (1,40,30,23,12,32,43,18,28,19,37,38,27,42,35,41,44,25), 'offset',$view_parameters.offset,'limit',$page_limit))}
{set search_result=$search['SearchResult']}
{set search_count=$search['SearchCount']}
{set stop_word_array=$search['StopWordArray']}
Thanks again. -Luke
|