1 of 2
1
Auto Search
Posted: 20 October 2005 03:04 PM   [ Ignore ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7509
Joined  08-05-2002

If anyone is interested, it is currently possibly to do auto searches in ExpressionEngine with a little bit of know how.  Observe this on my own weblog for various topics:

Rick Ellis
ExpressionEngine
Apple hardware

All it takes is a well designed template using the advanced search form with most fields preset and the keywords field set by segment.  Then, submit the form on load.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{lang}" lang="{lang}">

<
head>
<
title></title>
<
meta http-equiv="content-type" content="text/html; charset=utf-8" />
<
meta http-equiv="Content-Language" content="en-us" />
</
head>
<
body onload="document.forms[0].submit();">

{exp:search:advanced_form result_page="search/results" weblog="not journal"}
<input type="hidden" name="keywords" value="{segment_3}" />
<
input type="hidden" name="search_in" value="everywhere" />
<
input type="hidden" name="where" value="all" />
<
input type="hidden" name="weblog_id[]" value="1" />
<
input type="hidden" name="weblog_id[]" value="4" />
<
input type="hidden" name="date" value="0" />
<
input type="hidden" name="date_order" value="newer" />
<
input type="hidden" name="order_by" value="date" />
<
input type="hidden" name="sort_order" value="desc" />
{/exp:search:advanced_form}

</body>
</
html>

Thought a few of you might be interested, especially since EE 1.4 is going to allow custom fields and more variables in the search results.

 Signature 
Profile
 
 
Posted: 20 October 2005 03:13 PM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16153
Joined  05-15-2004
Paul Burdick - 20 October 2005 03:04 PM

Thought a few of you might be interested, especially since EE 1.4 is going to allow custom fields and more variables in the search results.

There, you’re doing it again!

This is actually seriously cool, by the way.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 20 October 2005 03:16 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7509
Joined  08-05-2002

Someone should really create an EE rumor site, especially considering the CTO and CEO do not know how to shut up.

 Signature 
Profile
 
 
Posted: 20 October 2005 04:59 PM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6086
Joined  08-04-2002

Custom fields in search results…Gimme, Gimme, Gimme big surprise

Profile
 
 
Posted: 20 October 2005 07:31 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  334
Joined  05-15-2004

Cookie Monster wants more!  More info!  mmm…...

Profile
 
 
Posted: 08 April 2006 08:43 AM   [ Ignore ]   [ # 5 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

I can’t seem to get the above code to work with categories. I have a list of categories on my homepage (based on the categories in my ‘article’ weblog) that I want to be links to search results for that category.

I’m using a generic word as a keyword that I know will appear in every article (that’s the only way I’ve been able to figure out how to search for ‘all’ within that category.

Here is the code in my search/auto template:

<body onload="document.searchform.submit();">

{exp:search:advanced_form result_page="method/results" weblog="articles"}
<input type="hidden" name="keywords" value="feld" />
<
input type="hidden" name="category_id" value="{segment_3}" />
<
input type="hidden" name="search_in" value="everywhere" />
<
input type="hidden" name="where" value="exact" />
{/exp:search:advanced_form}

And here are the two ways I’ve tried to set up the links:

<a href="{path=search/auto}">{category_name}</a><br />

and

<a href="/content/search/auto/{category_id}">{category_name}</a><br />

It seems to be ignoring the categories and instead just returns every article.

If you want to see what’s happening, it’s at:

http://64.62.135.203/

Just click one of the links in the green box on the right. (By the way, the regular search works fine).

By the way, the reason I’m not doing it as Paul did it in his example is that the titles of our categories will rarely turn up in the actual articles as keywords.

Thanks for any help!
Ken

Profile
 
 
Posted: 09 April 2006 10:42 AM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7509
Joined  08-05-2002

Well, if you notice, your links look like ‘C73’, which is the category ID with a C on the front.  So, basically, the search expects only the ID and not the ‘C’ on the front.  If you simply want to display all the entries in a category, you can just do that exact same manner of link to a page showing Weblog Entries and EE will see the URL and display all of the entries in that category.

http://64.62.135.203/content/method/article/C73/

 Signature 
Profile
 
 
Posted: 09 April 2006 01:02 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Rank
Total Posts:  76
Joined  09-26-2005

Thanks Paul. Actually, I was trying to get the articles to show up as search results, because our articles can be pretty long and it just seems less weblog-like to do it this way (among other reasons). Also, once I have all the articles published, they will be in the hundreds.

I got it working with a combination of your suggestion above (removing the ‘C’ from the URL) and another post, here:

http://expressionengine.com/forums/viewthread/11199/

I’ve made so many adjustments and changes over the last two days, and read so many forum posts, that I’m not really sure this is the best way to do this, but here is the code I’m using, just in case it’s useful to somebody else, or in case you have any suggestions for making it more efficient, etc. Now that it’s working, I’m afraid to even open the templates!!

search/auto template:

{exp:search:advanced_form result_page="method/results" weblog="articles"}

<div style="display: none;">
     <
select id="weblog_id[]" name="weblog_id[]" size="3">
     <
option value="10" selected="selected"></option>
     </
select>
</
div>

<
div style="display: none;">
     <
select id="cat_id[]" name="cat_id[]" size="3">
     <
option value="{segment_3}" selected="selected"></option>
     </
select>
</
div>


<
input type="hidden" name="keywords" value="feld" />
<
input type="hidden" name="where" value="any" />
<
input type="hidden" name="date" value="any_date" />
<
input type="hidden" name="search_in" value="everywhere" />

{/exp:search:advanced_form}

And here is the list of links:

<a href="/content/search/auto/{category_id}">{category_name}</a><br />

You can see it here:
http://64.62.135.203 - click one of the links in the green box

Profile
 
 
Posted: 21 October 2008 10:29 AM   [ Ignore ]   [ # 8 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007

very nice solution, but it works only for words without foreign sign, if you try using it with it, you get

Disallowed Key Characters

maybe this will be improoved in EE2.0 smile

Profile
 
 
Posted: 21 October 2008 01:24 PM   [ Ignore ]   [ # 9 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16153
Joined  05-15-2004

What browser are you using? Although umlauts and such are technically invalid in a URL, I have never had problems with that. (My testsite)

Tested with Chrome, Opera and Firefox.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 21 October 2008 01:39 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007

hmm strange…

I tried the same word, but the same problem, maybe is something with the html on that auto page
http://www.zooshopamazona.hr/pretraga/auto/Österreich
here you can try something

and this is the code, maybe I’m missing something

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html >
<
head>

<
title>Pretraga</title>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
meta http-equiv="Content-Language" content="hr" />
</
head>
<
body>


{exp:search:advanced_form weblog="products" status="open" result_page="pretraga" results="25" no_result_page="pretraga/bez-rezultata" where="exact" search_in="everywhere"}
<input type="hidden" name="keywords" value="{segment_3}" />
<
input type="hidden" name="search_in" value="entries" />
<
input type="hidden" name="where" value="all" />
<
input type="hidden" name="orderby" value="title" />
<
input type="hidden" name="sort_order" value="asc" />
{/exp:search:advanced_form}

</body>
</
html>

Profile
 
 
Posted: 21 October 2008 02:29 PM   [ Ignore ]   [ # 11 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16153
Joined  05-15-2004

This message almost always means the server is trying to set an unsafe cookie. You can try to edit core.input.php around line 410 change:

exit('Disallowed Key Characters');


into

exit('Disallowed Key Characters: '.$str);

When you get the message again it will also show the key that’s triggering the error.

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 21 October 2008 07:13 PM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007

thanx ingmar, but without result.
maybe is something in the code, can you compare it with yours?

thanx

Profile
 
 
Posted: 30 October 2008 09:43 AM   [ Ignore ]   [ # 13 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007
Ingmar Greil - 21 October 2008 02:29 PM

This message almost always means the server is trying to set an unsafe cookie. You can try to edit core.input.php around line 410 change:

exit('Disallowed Key Characters');


into

exit('Disallowed Key Characters: '.$str);

When you get the message again it will also show the key that’s triggering the error.

I remembered that I didn’t deleted cache…
Now I get the error.. but for me, it doesn’t mean anything :(

for search /pretraga/auto/kunić
Disallowed Key Characters: /pretraga/auto/kuni

Thanx Ingmar

Profile
 
 
Posted: 30 October 2008 01:41 PM   [ Ignore ]   [ # 14 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  16153
Joined  05-15-2004

What browser are you using? What encoding? Looks like ‘ć’ is actually translated into two unprintable characters. I can only assume it’s got to do with your server setup, since it works for me. Sorry, this is really not something we can support :(

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 30 October 2008 01:49 PM   [ Ignore ]   [ # 15 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007
Ingmar Greil - 30 October 2008 01:41 PM

What browser are you using? What encoding? Looks like ‘ć’ is actually translated into two unprintable characters. I can only assume it’s got to do with your server setup, since it works for me. Sorry, this is really not something we can support :(

hi

I tried in firefox 3 and safari, utf-8
also tried cleaning cookies, but without help :(

normal searching is working great, but this I dont know why not.

do you know where I can search o what to ask my hosting company to change?

thanx

Profile
 
 
Posted: 30 October 2008 02:28 PM   [ Ignore ]   [ # 16 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007

Don’t worry, I don’t expect from you to support this, as is custom work out.

I contacted hosting company, so,, we will see..

Danke

Profile
 
 
Posted: 30 October 2008 05:33 PM   [ Ignore ]   [ # 17 ]  
Grad Student
Avatar
Rank
Total Posts:  57
Joined  10-18-2007

I’m not sure if this point in new version 165 have something to do with it

Modified Cookie key processing to relieve “Disallowed Key Characters” errors in certain environments.

Profile
 
 
Posted: 31 October 2008 04:07 AM   [ Ignore ]   [ # 18 ]  
Lab Assistant
RankRank
Total Posts:  148
Joined  03-05-2008

just as a side note… those two strange characters coming up at the end have translated to chinese / japanese characters… not my speciality! Where is the server being hosted????!!!

 Signature 

Stock Photo & Vectors - Free Stock Photos - Free Stock Vectors

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66392 Total Logged-in Users: 28
Total Topics: 84717 Total Anonymous Users: 21
Total Replies: 454703 Total Guests: 194
Total Posts: 539420    
Members ( View Memberlist )