Forums / Developer / Please help the Newbie...

Please help the Newbie...

Author Message

Koos TDK

Monday 13 September 2004 7:27:54 am

Hi I have searched the forums but I'm still not sure how to do this. I am sure it must be very easy. Any help from the guru's on the forum will be much appreciated!

OK, <b>Step1:</b> On my site, I want people to be able to search for companies or products. This is easy as per the docs(restricting a search by class):

<form action="/content/advancedsearch/" 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="SearchContentClassID" value="14" />
</form>

Now, my problem <b>Step 2:</b> I want the person doing the search, to only see results for a specific REGION/COUNTY/STATE(whatever you wish to call it :-)) which is available via a drop-down list.

Thus, he/she can search for "Oranges" in "Ohio" and he/she will only see anything related to Oranges in Ohia and no other state.

I have created a custom "CP_Company" class with "Region" being a "Selection" attribute. How would I allow a search in all other attributes of this class, BUT only results with the selected "Region" attribute value will be displayed?

Thanks for any help!!! :-)

Lazaro Ferreira

Monday 13 September 2004 11:27:05 am

Hi,

You will have to create a custom search page, using the search operator

Look at this URL
http://ez.no/ez_publish/documentation/reference/data_fetching/content/search

Lazaro

Lazaro
http://www.mzbusiness.com

Koos TDK

Tuesday 14 September 2004 12:28:23 am

Hi Lazaro

Thanks for your help. I have had a look at the search operator, but I have been lost(or just too stupid!) in figuring out how to get the search done since it seems to be a "dual" search solution, i.e. 1.) I will get the text the person want to search for from a text box on the website(say it is "orange" for argument's sake), then 2.) he/she selects a geographical region from a drop-down list for which to filter(say "ohio" for argument's sake).(The value will be available from what the person has selected in the drop-down list).

<b>Thus EZP must be able to search:</b>
1.) For the text "orange" only in my custom content class(id=32)
2.) But only return results where "ohio" matches the text in the "region" attribute(id=245) of content class 32, which is of datatype "selection". I have added the possible options that can be selected as elements of the "selection" datatype, so those values are static.

THANKS!! :-)

Koos TDK

Tuesday 14 September 2004 7:35:12 am

OK, have done some testing, but so far a bit disappointing.

The following code in pagelayout.tpl allows the user to enter text to search for in a form. This search is only done against the "Region" attribute of the class.

This is the second part of the solution to my problem. But how do I do the MAIN search in the rest of the attributes with this solutions as the "filter" or "constraint"?? A looped search? Is there an easier way or am I missing somethin?

<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="SearchContentClassID" value="32" />
<input type="hidden" name="SearchContentClassAttributeID" value="245" />
</form> 

Thanks!

Koos TDK

Wednesday 15 September 2004 4:53:27 am

Hi!

Using version 3.4.1

It seems like the code below should give me the required results(According to all my research on the forums). But it does not return ANY results and there are no debugging errors being returned! (Yes, there is a single item that matches an "and" on those attributes and values).

<b>I have this code in my "pagelayout.tpl" file -- should it maybe be somewhere else? Could this be the problem?</b>

{section loop=fetch(content,tree,hash(parent_node_id, 105, attribute_filter,
 array(and,array(240,'like','%orange%'), array(245,'like','%ohio%'))))
}
{$:item.name}
{/section}

Any help will be much appreciated!

Paul Borgermans

Wednesday 15 September 2004 5:09:47 am

Did you use the patched ezcontentobjecttreenode.php file from teh contributions? the 'like' operator is not supported by default.

hth

-paul

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

Koos TDK

Thursday 16 September 2004 7:27:40 am

Hi Paul

Thanks for the reply. Yes, I have copied the new ezcontentobjecttreenode.php to "/kernel/classes".

I have tested only filtering on a single attribute and it works 100%, like so:

{section loop=fetch(content,list,hash(parent_node_id, 105, attribute_filter,
 array(and,array(240,'like','%orange%'))))
}

This then returns only entries with "orange" in attribute 240.(But only the value of the first attribute in the object).

BUT there is a problem when trying to filter on a second attribute, it does not return any results! Even when specifying to search for "%" in the firts attribute and "%n%" in the other, it returns nothing, the code:

{section loop=fetch(content,list,hash(parent_node_id, 105, attribute_filter, 
array(and, array(240,'like','%'), array(245,'like','%n%'))))
}

Also, the fetch only returns the value of the very first attribute of the object, I have tried changing the "list" to "tree" but I don't see any difference in the results.

This is driving me mad, so close, but it just doesn't want to work!!

ANY help greatly appreciated(again!) :-)

Andrew Vorobyov

Sunday 29 May 2005 12:42:29 am

Koos is not alone!

please help folks...