Forums / Install & configuration / Customise my (search)form

Customise my (search)form

Author Message

Nabil Alimi

Wednesday 15 June 2005 5:00:59 am

Hi,

I'm trying to build my own search form...

My template action is itself.

<form action={"/recherche_d_une_formation/"|ezurl} method="get">
	<div class="">Choix d'une fili&egrave;re</div>	
	<select name="filiere">
		<option value=""> Choisir une fili&egrave;re </option>
	{let l_filieres=fetch(content,list,hash(parent_node_id,86,class_filter_array,array(19)))}
		{section var=filiere loop=$l_filieres}
		<option value="{$filiere.node_id}">{$filiere.name}</option>
		{/section}
	{/let}
	</select>
	<div class="">Choix d'un type</div>
		<select name="type">
			<option value=""> Choisir un type </option>
	{let l_types=fetch(content,list,hash(parent_node_id,87,class_filter_array,array(19)))}	
		{section var=type loop=$l_types}
			<option value="{$type.node_id}">{$type.name}</option>
		{/section}
	{/let}
	</select>
	<div class="">Nombre de formations &agrave; afficher</div>
	<select name="page_limit">
		<option value="5">5</option>
		<option value="10">10</option>
		<option value="15">15</option>
		<option value="20">20</option>
	</select>
	<input type="hidden" name="SubTreeArray[]" value="105" />
	<input type="hidden" name="SearchContentClassID" value="14" />
	<input type="hidden" name="searchon" value="1" />
	<input type="submit" class="searchbutton" name="SearchButton" value="Search" />
</form>

How can I retrieve vars from the form ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Paul Borgermans

Wednesday 15 June 2005 8:46:31 am

Hi

That is easy (really) :-)

Just turn off caching for this particular template and use the template operator ezhttp:

http://ez.no/ez_publish/documentation/reference/template_operators/data_extraction/ezhttp

To disable caching, use

{set-block scope=root variable=cache_ttl}0{/set-block}

at the start of your template

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Nabil Alimi

Thursday 16 June 2005 4:02:26 am

That works fine, thanks Paul.

But now, I have an other little problem.

I'd like to make search on a relation of my class.

So. I have my class "formation" (the main) witch has a
relation with class "type".
I found that the node_id of the type linked with my formation was stored in $node.object.data_map.type.content.main_node_id .
I'd like to make my search on this criteria. By displaying only "formations" having type "long" whose node_id is "91" for example.

So is there a way to test this directly in the fetch function ? Or will I have to had a "{section show..." statement ?

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Nabil Alimi

Wednesday 22 June 2005 1:58:37 am

Hi,

If I want to create a custom search form that calls back the same template, am I forced to use the default search.tpl ? Cause I've tried something and it doesnt seem to work...

{set-block scope=root variable=cache_ttl}0{/set-block}
<form action={"/recherche_d_un_centre/"|ezurl} method="get">
<label>Nom du centre : </label>
<input class="searchbox" type="text" size="8" name="SearchText" id="Search" />
<input class="searchbutton" name="SearchButton" type="submit" value="Rechercher" />
<input type="hidden" name="SearchContentClassID" value="26" />
<input type="hidden" name="SearchContentClassAttributeID" value="244" />
</form>
{let src_txt=ezhttp('SearchText','get') src_class_attribute_id=ezhttp('SearchContentClassAttributeID','get') src_content_class_id=ezhttp('SearchContentClassID','get')}
	{$src_txt} {$src_class_attribute_id}
	{section show=is_set($src_txt)}
		{let search=fetch(content,search,
		                      hash(text,$src_txt,
		                           subtree_array,array(113),
								   class_id,$src_content_class_id,
		                           class_attribute_id,array($src_class_attribute_id))) 
								   }
			{let search_result=$search['SearchResult']}			   
			{section loop=$search_result var=un_resultat}
				{$un_resultat.number}{$un_resultat.name}
			{/section}
			{/let}
		{/let}			
	{/section}
{/let}

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr