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} 

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 21:07:57
Script start
Timing: Jan 18 2025 21:07:57
Module start 'layout'
Timing: Jan 18 2025 21:07:57
Module start 'content'
Timing: Jan 18 2025 21:07:58
Module end 'content'
Timing: Jan 18 2025 21:07:58
Script end

Main resources:

Total runtime0.8189 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 589.1797152.6406
Module start 'layout' 0.00630.0033 741.820339.4766
Module start 'content' 0.00960.8078 781.2969591.2344
Module end 'content' 0.81740.0015 1,372.531324.4375
Script end 0.8189  1,396.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4363160.0002
Check MTime0.00130.1578160.0001
Mysql Total
Database connection0.00100.127010.0010
Mysqli_queries0.752991.9387600.0125
Looping result0.00060.0718580.0000
Template Total0.784095.720.3920
Template load0.00260.322620.0013
Template processing0.781495.418020.3907
Template load and register function0.00050.055110.0005
states
state_id_array0.00070.087410.0007
state_identifier_array0.00110.131020.0005
Override
Cache load0.00210.2570270.0001
Sytem overhead
Fetch class attribute can translate value0.00070.081420.0003
Fetch class attribute name0.00120.148150.0002
XML
Image XML parsing0.00070.089020.0004
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00080.1028160.0001
String conversion0.00000.001540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs