Forums / Developer / Search on ezselection and ezrelatedobject

Search on ezselection and ezrelatedobject

Author Message

Andrew Vorobyov

Thursday 02 June 2005 11:45:40 am

Hello, please explain to the idiot..

I have object with 4 ezselection attr and 3 object relation attr.

<b>How can I carry out search by these fields?</b>

					attribute_filter, array(
  array('object/ezselection_attr_country','=','USA')
 )
)

It's NOT working!!!
I spent whole day digging this - no results...
I'm in despair and thinking about suicide!!

Help me pls...

Andrew Vorobyov

Thursday 02 June 2005 10:01:58 pm

I did it...

You should source $node.contentobject_id of your relation objects...

Xavier Dutoit

Friday 03 June 2005 9:38:47 am

Hi Andrew,

Glad to know you've found and that you haven't commited suicide ;)

Anyway, could you post the template code you've written to solve your problem, as it might help others too ?

X+

http://www.sydesy.com

Andrew Vorobyov

Wednesday 08 June 2005 12:23:09 pm

Maybe it will help to somebody...

There are <b>ezselection</b> and <b>ezrelation</b> attributes in this search.

This is the search form:

<form action={"/content/advancedsearch/my"|ezurl} method="post">
  <div whitespace=nowrap>


   <input id="searchbutton" class="button" name="SearchButton" type="submit" value="Search" />
   <input type="hidden" name="Content_search_attribute_fulltext_classattribute_id[]" value="224" />
    By country: <select name="Content_search_attribute_fulltext_value[]">
		{let attr1=fetch( 'content', 'class_attribute', hash( 'attribute_id', 224) )}
		
		{section var = country loop = fetch('content','list',hash(
							'parent_node_id',$attr1.content.default_selection_node
							))
		}
		 <option value="{$country.name|wash}">{$country.name|wash}</option>
		 {/section}
		{/let}
              </select>

   <input type="hidden" name="Content_search_attribute_fulltext_classattribute_id[]" value="228" />
    By city: 
	<select name="Content_search_attribute_fulltext_value[]">
		{let attr2=fetch( 'content', 'class_attribute', hash( 'attribute_id', 228) )}
		{section var = city loop = fetch('content','list',hash(
							'parent_node_id',$attr2.content.default_selection_node
							))
		}
		<option value="{$city.name|wash}">{$city.name|wash}</option>			
		{/section}
		{/let}
	</select>

   </div>
  <input type="hidden" name="SubTreeArray" value="95"  />
  <input type="hidden" name="SearchContentClassID" value="25"  / >
</form>

<table border=0 width="100%">
<tr>
{section loop = fetch('content','list',hash(
						'parent_node_id',$node.node_id
					)
		)
}		<td>
		<a href={$:item.url_alias|ezurl}>{$:item.name}</a> - age {$:item.data_map.age.value}<br>
		{attribute_view_gui attribute=$:item.data_map.photo image_class='small'}
		</td>
	{delimiter modulo=3}
		  </tr>
		  <tr>
	{/delimiter}
{/section}
</tr>
</table>

Here goes processing:

{def $params = hash(
		'offset', cond(ezhttp( 'offset','post' ),ezhttp( 'offset','post' ),true(),0)|int,
		'limit', cond(ezhttp( 'limit','post' ),ezhttp( 'limit','post' ),true(),2)|int,
		'agefrom', ezhttp( 'agefrom','post' ),
		'ageto', ezhttp( 'ageto','post' ),
		'heightfrom', ezhttp( 'heightfrom','post' ),
		'heightto', ezhttp( 'heightto','post' ),
		'weightfrom', ezhttp( 'weightfrom','post' ),
		'weightto', ezhttp( 'weightto','post' ),
		'eyes', ezhttp( 'eyes','post' ),
		'hair', ezhttp( 'hair','post' ),
		'marital', ezhttp( 'marital','post' ),
		'children', ezhttp( 'children','post' ),
		'english', ezhttp( 'english','post' ),
		'language', ezhttp( 'language','post' ),
		'religion', ezhttp( 'religion','post' ),
		'country', ezhttp( 'country','post' ),
		'city', ezhttp( 'city','post' )
		)
} 

{*$params|attribute(show,2)*}
{def $search_params = array()}

{if $params.agefrom|ne('')}
{def $search_params = $search_params|append(array('woman/age','>=',$params.agefrom))}
{/if}

{if $params.ageto|ne('')}
{def $search_params = $search_params|append(array('woman/age','<=',$params.ageto))}
{/if}

{if $params.heightfrom|ne('')}
{def $search_params = $search_params|append(array('woman/height','>=',$params.heightfrom))}
{/if}

{if $params.heightto|ne('')}
{def $search_params = $search_params|append(array('woman/height','<=',$params.heightto))}
{/if}

{if $params.weightfrom|ne('')}
{def $search_params = $search_params|append(array('woman/weight','>=',$params.weightfrom))}
{/if}

{if $params.weightto|ne('')}
{def $search_params = $search_params|append(array('woman/weight','<=',$params.weightto))}
{/if}

{if $params.eyes|ne('')}
{def $search_params = $search_params|append(array('woman/eyes','=',$params.eyes))}
{/if}

{if $params.hair|ne('')}
{def $search_params = $search_params|append(array('woman/hair','=',$params.hair))}
{/if}

{if $params.marital|ne('')}
{def $search_params = $search_params|append(array('woman/marital','=',$params.marital))}
{/if}

{if $params.children|ne('')}
{def $search_params = $search_params|append(array('woman/children','=',$params.children))}
{/if}

{if $params.religion|ne('')}
{def $search_params = $search_params|append(array('woman/religion','=',$params.religion))}
{/if}

{if $params.english|ne('')}
{def $search_params = $search_params|append(array('woman/english','>=',$params.english))}
{/if}

{if $params.country|ne('')}
{def $search_params = $search_params|append(array('woman/country','=',$params.country|int))}
{/if}

{if $params.city|ne('')}
{def $search_params = $search_params|append(array('woman/city','=',$params.city|int))}
{/if}

{* $search_params|attribute(show,2) *}

{def $women = fetch( 'content','tree',
       hash( parent_node_id, 114,
		offset,$params.offset,
		limit,$params.limit,
		class_filter_type, include,
		class_filter_array, array('woman'),
		attribute_filter, $search_params
	)
	)

$total = fetch( 'content','tree_count',
       hash( parent_node_id, 114,
		class_filter_type, include,
		class_filter_array, array('woman'),
		attribute_filter, $search_params
	)
	)

}

{section show=$total|gt($limit)}
Total women found: <b>{$total}</b><br>

<TABLE border="0" cellspacing=5>
<TR>
{section var=woman loop=$women}
{node_view_gui content_node=$woman view='line'}
{/section}
</TR>
</TABLE>

{def $total_pages = $total|div($params.limit|int)|ceil}
<TABLE border="0" cellspacing=5>
<TR>
<TD>
<form action={"/content/advancedsearch/searchforwoman"|ezurl} method="post">
	<input type="hidden" name="offset" value="0"/>
	<input type="hidden" name="limit" value="{$params.limit}"/>
	<input type="hidden" name="agefrom" value="{$params.agefrom}"/>
	<input type="hidden" name="ageto" value="{$params.ageto}"/>
	<input type="hidden" name="heightfrom" value="{$params.heightfrom}"/>
	<input type="hidden" name="heightto" value="{$params.heightto}"/>
	<input type="hidden" name="eyes" value="{$params.eyes}"/>
	<input type="hidden" name="hair" value="{$params.hair}"/>
	<input type="hidden" name="marital" value="{$params.marital}"/>
	<input type="hidden" name="children" value="{$params.children}"/>
	<input type="hidden" name="language" value="{$params.language}"/>
	<input type="hidden" name="english" value="{$params.english}"/>
	<input type="hidden" name="religion" value="{$params.religion}"/>
	<input type="hidden" name="country" value="{$params.country}"/>
	<input type="hidden" name="city" value="{$params.city}"/>
	<input class="searchbutton" name="SearchButton" type="submit" value="|<"}"/>
</form>
</TD>
{for 0 to $total_pages|sub(1) as $i}
<TD>
<form action={"/content/advancedsearch/searchforwoman"|ezurl} method="post">
	<input type="hidden" name="offset" value="{mul($i,$params.limit)}"/>
	<input type="hidden" name="limit" value="{$params.limit}"/>
	<input type="hidden" name="agefrom" value="{$params.agefrom}"/>
	<input type="hidden" name="ageto" value="{$params.ageto}"/>
	<input type="hidden" name="heightfrom" value="{$params.heightfrom}"/>
	<input type="hidden" name="heightto" value="{$params.heightto}"/>
	<input type="hidden" name="eyes" value="{$params.eyes}"/>
	<input type="hidden" name="hair" value="{$params.hair}"/>
	<input type="hidden" name="marital" value="{$params.marital}"/>
	<input type="hidden" name="children" value="{$params.children}"/>
	<input type="hidden" name="language" value="{$params.language}"/>
	<input type="hidden" name="english" value="{$params.english}"/>
	<input type="hidden" name="religion" value="{$params.religion}"/>
	<input type="hidden" name="country" value="{$params.country}"/>
	<input type="hidden" name="city" value="{$params.city}"/>
	<input class="searchbutton" name="SearchButton" type="submit" value="{$i|inc}"/>
</form>
</TD>
{/for}
<TD>
<form action={"/content/advancedsearch/searchforwoman"|ezurl} method="post">
	<input type="hidden" name="offset" value="{mul($total_pages|sub(1),$params.limit)}"/>
	<input type="hidden" name="limit" value="{$params.limit}"/>
	<input type="hidden" name="agefrom" value="{$params.agefrom}"/>
	<input type="hidden" name="ageto" value="{$params.ageto}"/>
	<input type="hidden" name="heightfrom" value="{$params.heightfrom}"/>
	<input type="hidden" name="heightto" value="{$params.heightto}"/>
	<input type="hidden" name="eyes" value="{$params.eyes}"/>
	<input type="hidden" name="hair" value="{$params.hair}"/>
	<input type="hidden" name="marital" value="{$params.marital}"/>
	<input type="hidden" name="children" value="{$params.children}"/>
	<input type="hidden" name="language" value="{$params.language}"/>
	<input type="hidden" name="english" value="{$params.english}"/>
	<input type="hidden" name="religion" value="{$params.religion}"/>
	<input type="hidden" name="country" value="{$params.country}"/>
	<input type="hidden" name="city" value="{$params.city}"/>
	<input class="searchbutton" name="SearchButton" type="submit" value=">|"}"/>
</form>
</TD>
</TR>
</TABLE>
{/section}