The attached add-on files may be out of date. Please visit Devot-ee for the latest versions.
This plugin allows you to create custom search engines using Yahoo! BOSS API.
THE TAG {exp:yboss:form}
I. Config variables/parameters:
You can either define parameters of the tag or edit plugin’s config. Parameters’ values take precedence over the values of config variables.
1) app_id - required. Get it at https://developer.yahoo.com/wsregapp/
2) term_element - required. Enter the name of the form element whose value contains search terms.
3) api_version - optional. Enter Yahoo! BOSS API version number. Default value is “1”.
4) sites - optional. Enter URLs to restrict the search to. “http://www.” part or the URLs not necessary. Default value is “all”, which means that all web will be searched. You can stack two or more values using pipe character, e.g. “myfirstsite.com|mysecondsite.net”
5) searchin - optional. Possible values: web, images, news.
6) limit - optional. Number of items per page (min 10, max 50). Default value is “20”.
7) age - optional. Used only for news search. Indicates many days old news items might be (min 7, max 1000). Default value is “180d”.
8) orderby - optional. Used only for news search. Indicates how news items should be ordered (possible values: relevance, date). Default value is “relevance”.
9) validate_form - optional. Possible values: yes/no. Default id “yes”. If the value is set to “yes”, then client-side script will perform simple validation of user input.
10) help_button - optional. Allows you to specify “id” attribute of HTML element which will be used by client-side script. Client-side script will display simple help dialog. After defining this variable/parameter, e.g. help_button=”helpbutton”, you will need to add to add some HTML inside your search form, e.g.
<button id="helpbutton" type="button">Help</button>
11) limit_button - optional. Allows you to specify “id” attribute of HTML element which will be used by client-side script. Client-side script will display simple dialog allowing to choose number of items per page. After defining this variable/parameter, e.g. limit_button=”limitbutton”, you will need to add to add some HTML inside your search form, e.g.
<button id="limitbutton" type="button">Limit</button>
12) limit_selectbox - optional. Allows you to specify “id” attribute of HTML <select> element which will be used by client-side script. Client-side script will allow to choose number of items per page. After defining this variable/parameter, e.g. limit_selectbox=”limitselect”, you will need to add to add some HTML inside your search form, e.g.
<select name="count" id="limitselect">
<option value="">Limit</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20" selected="selected">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
</select>
13) age_button - optional. Allows you to specify “id” attribute of HTML element which will be used by client-side script. Client-side script will display simple dialog allowing to choose number of days how old news items can be. After defining this variable/parameter, e.g. age_button=”agebutton”, you will need to add to add some HTML inside your search form, e.g.
14) age_selectbox - optional.Allows you to specify “id” attribute of HTML <select> element which will be used by client-side script. Client-side script will allow to choose number of days how old news items can be. After defining this variable/parameter, e.g. age_selectbox=”ageselect”, you will need to add to add some HTML inside your search form, e.g.
Continued in the next post.
15) orderby_button - optional. Allows you to specify “id” attribute of HTML element which will be used by client-side script. Client-side script will display simple dialog allowing to choose how news items should be ordered (by date or by relevance). After defining this variable/parameter, e.g. age_button=”orderbybutton”, you will need to add to add some HTML inside your search form, e.g.
16) orderby_selectbox - optional. Allows you to specify “id” attribute of HTML <select> element which will be used by client-side script. Client-side script will allow to choose how news items should be ordered (by date or by relevance). After defining this variable/parameter, e.g. orderby_selectbox=”orderbyselect”, you will need to add to add some HTML inside your search form, e.g.
17) searchin_radios - optional. Allows you to specify “id” attributes of HTML <input type=”radio”> elements which will be used by client-side script. Client-side script will allow to choose what should be searched (web or images or news). After defining this variable/parameter, e.g. searchin_radio=”web_radio|images_radio|news_radio”, you will need to add to add some HTML inside your search form, e.g.
Search in:
<input type="radio" id="web_radio" name="searchin" value="web" checked="checked" /> Web
<input type="radio" id="images_radio" name="searchin" value="images" /> Images
<input type="radio" id="news_radio" name="searchin" value="news" /> News
18) searchin_selectbox - optional. Allows you to specify “id” attribute of HTML <select> element which will be used by client-side script. Client-side script will allow to choose what should be searched (web or images or news). After defining this variable/parameter, e.g. searchin_selectbox=”searchinselect”, you will need to add to add some HTML inside your search form, e.g.
<select name="searchin" id="searchinselect">
<option value="">Search in</option>
<option value="web" selected="selected">web</option>
<option value="images">images</option>
<option value="news">news</option>
</select>
19) sites_radios - optional. Allows you to specify “id” attributes of HTML <input type=”radio”> elements which will be used by client-side script. Client-side script will allow to choose what URLs search should be restricted to. After defining this variable/parameter, e.g. sites_radios=”mysites_radio|internet_radio”, you will need to add to add some HTML inside your search form, e.g.
Sites:
<input type="radio" name="sites" id="mysites_radio" value="myfirstsite.com mysecondsite.net" checked="checked" /> My sites
<input type="radio" name="sites" id="internet_radio" value="all" /> Internet
20) sites_selectbox - optional. Allows you to specify “id” attribute of HTML <select> element which will be used by client-side script. Client-side script will allow to choose what URLs search should be restricted to. After defining this variable/parameter, e.g. sites_selectbox=”sitesselect”, you will need to add to add some HTML inside your search form, e.g.
<select name="sites" id="sitesselect">
<option value="">Sites</option>
<option value="myfirstsite.com mysecondsite.net" selected="selected">my sites/option>
<option value="all">whole internet</option>
</select>
21) normalize_unicode - optional. Allows you to specify if search terms should be converted into unicode’s normalization form C. Possible values - yes/no. Default value is “no”. To convert search terms into unicode’s normalization form C you should either use PHP version 5.3 or higher or have PHP extension PECL intl installed.
II. Variables:
1) {yboss_search_term} - outputs search term.
Continued in the next post
THE TAG {exp:yboss:results}
I. Config variables/parameters:
1) max_links - optional. Allows you to specify how many pagination links should be displayed. Default value is “5”.
2) hide_keywords - optional. Used only for web search. Allows you to specify if client-side script should be injected which will allow to show/hide keywords list.
3) result_item_class - optional. Used only for web search. Allows you to specify “class” attribute of HTML element which wraps each result item. Will be used by client-side script to show/hide keywords list. Default is “result_item”.
4) keyterms_label_class - optional. Used only for web search. Allows you to specify “class” attribute of HTML element which wraps keyterms label. Will be used by client-side script to show/hide keywords list. Default is “show_keyterms”.
5) keyterms_on_class - optional. Used only for web search. Allows you to specify “class” attribute of HTML element which wraps keyterms. Will be used by client-side script to show keywords list. Default is “keyterms_on”.
6) keyterms_off_class - optional. Used only for web search. Allows you to specify “class” attribute of HTML element which wraps keyterms. Will be used by client-side script to hide keywords list. Default is “keyterms_off”.
7) normalize_unicode - optional. Allows you to specify if serch terms should be converted into unicode’s normalization form C. Possible values - yes/no. Default value is “no”. To convert search terms into unicode’s normalization form C you should either use PHP version 5.3 or higher or have PHP extension PECL intl installed.
II. Variable pairs:
1) {yboss_paginate_top}{/yboss_paginate_top} - used to output info and pagination on the top of results page. Contents of this variable pair will be outputted one time.
2) {yboss_paginate_bottom}{/yboss_paginate_bottom} - used to output info and pagination on the bottom of results page. Contents of this variable pair will be outputted one time.
3) {yboss_keyterm_list}{/yboss_keyterm_list} - used only in web search. Contents of this variable pair will be iterated as many times as there are keyterms.
III. Variables used in web/images/news search:
1) yboss_search_term - outputs search term(s).
2) yboss_searchin - otputs type of search - web or images or news.
3) yboss_total_results - number of results found.
4) yboss_first_result_count - count number of the first item on page.
5) yboss_last_result_count - count number of the last item on page.
6) yboss_pagination_links - outputs pagination links.
7) yboss_title - title of the item.
8) yboss_url - url of the item.
9) yboss_clickurl - click url of the item.
10) yboss_abstract - abstract of the item.
11) yboss_date - date of the item.
Continued in the next post
IV. Variables used only in web search:
1) yboss_dispurl_web - URL formatted for display.
2) yboss_size_web - size (in bytes) of the web page.
3) yboss_keyterms_count_web - number of keyterms.
4) yboss_keyterm_url_web - URL for search based on keyterm.
5) yboss_keyterm_web - keyterm.
V. Variables used only in images search:
1) yboss_size_img - size (in bytes) of the image.
2) yboss_filename_img - filename of image.
3) yboss_format_img - format of the image.
4) yboss_mimetype_img - mimetype of the image.
5) yboss_height_img - height (in pixels) of the image.
6) yboss_width_img - width (in pixels) of the image.
7) yboss_thumbnail_url_img - URL of the thumbnail.
8) yboss_thumbnail_height_img - height (in pixels) of the thumbnail.
9) yboss_thumbnail_width_img - width (in pixels) of the thumbnail.
10) yboss_refererurl_img - URL of the page picture belons to.
11) yboss_refererclickurl_img - click URL of the page picture belons to.
VI. Variables used only in news search:
1) yboss_source_news - name of the news source.
2) yboss_sourceurl_news - URL of the news source.
EXAMPLE OF SEARCH FORM PAGE CODE
<html>
<head>
</head>
<body>
{exp:yboss:form term_element="for" app_id="tBJB48rjfffhdgfsddfs7gDOknQMxrXr.i4H9r1.Q.f75uhjfghdhgdhgdghaUPj5Fijo-" help_button="helpbutton" limit_selectbox="limitselect" searchin_selectbox="searchinselect" age_selectbox="ageselect" orderby_selectbox="orderbyselect" sites_selectbox="sitesselect"}
<form id="search_form" action="{path="mytemplategroup/mytemplate"}" method="get" accept-charset="utf-8">
<input type="text" name="for" size="100" value="{yboss_search_term}" /><input type="submit" value="Go" ><button id="helpbutton" value="">?</button>
<select name="count" id="limitselect">
<option value="">Limit</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20" selected="selected">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
</select>
<select name="sites" id="sitesselect">
<option value="">Sites</option>
<option value="myfirstsite.com mysecondsite.net" selected="selected">my sites</option>
<option value="all">whole internet</option>
</select>
<select name="searchin" id="searchinselect">
<option value="">Search in</option>
<option value="web" selected="selected">web</option>
<option value="images">images</option>
<option value="news">news</option>
</select>
<select name="age" id="ageselect">
<option value="">age</option>
<option value="7d">7d</option>
<option value="14d">14d</option>
<option value="30d">30d</option>
<option value="60d">60d</option>
<option value="90d">90d</option>
<option value="180d" selected="selected">180d</option>
<option value="365d">365d</option>
<option value="500d">500d</option>
<option value="1000d">1000d</option>
</select>
<select name="orderby" id="orderbyselect">
<option value="">Orderby</option>
<option value="relevance" selected="selected">relevance</option>
<option value="date">date</option>
</select>
</form>
{/exp:yboss:form}
</body>
</html>
Continued in the next post
Laisvunas,
This looks like a pretty cool plugin. I don’t want you to take this the wrong way but why is this needed? Maybe there is another thread about this but why use Yahoo Boss instead of some other search technology? Is this better than the built-in EE search? What problems does this solve on an EE-based website? Do you need to install a code library or anything?
Thanks, Bob.
Hi Bob,
EE search module is quite weak; you can read many criticism and suggestions here. It is also quite slow. Notice that EllisLab’s websites do not use it.
The best solution for search functionality is to provide a sitemap (using Sitemap module or some PHP script as that from xml-sitemaps.com) to the search service provides such as Google and Yahoo and to create some custom search engine.
Best known APIs for creating custom search engines are Google’s CSE and Yahoo’s BOSS.
Yahoo BOSS API is less intrusive: Yahoo does not require to put its logos on your page. Also it has such nice features as image search and news search.
You can see custom search engine implemented using this plugin in action here.
I’m trying to get this to work on a site I’m developing. I’ve copied and pasted the code from above, and replaced the app_id with my Yahoo app id. Here’s the code I’m using:
Search form template
<html>
<head>
</head>
<body>
{exp:yboss:form term_element="for" app_id="sPT7oy7V34HMAuTI7eBqzTmrCpKuLYBERprW.r5lcQxgEwyCVlNi.tRkHC.fa9I- " help_button="helpbutton" limit_selectbox="limitselect" searchin_selectbox="searchinselect" age_selectbox="ageselect" orderby_selectbox="orderbyselect" sites_selectbox="sitesselect"}
<form id="search_form" action="{path="search/results"}" method="get" accept-charset="utf-8">
<input type="text" name="for" size="100" value="{yboss_search_term}" /><input type="submit" value="Go" ><button id="helpbutton" value="">?</button>
<select name="count" id="limitselect">
<option value="">Limit</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20" selected="selected">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
</select>
<select name="sites" id="sitesselect">
<option value="">Sites</option>
<option value="myfirstsite.com mysecondsite.net" selected="selected">my sites</option>
<option value="all">whole internet</option>
</select>
<select name="searchin" id="searchinselect">
<option value="">Search in</option>
<option value="web" selected="selected">web</option>
<option value="images">images</option>
<option value="news">news</option>
</select>
<select name="age" id="ageselect">
<option value="">age</option>
<option value="7d">7d</option>
<option value="14d">14d</option>
<option value="30d">30d</option>
<option value="60d">60d</option>
<option value="90d">90d</option>
<option value="180d" selected="selected">180d</option>
<option value="365d">365d</option>
<option value="500d">500d</option>
<option value="1000d">1000d</option>
</select>
<select name="orderby" id="orderbyselect">
<option value="">Orderby</option>
<option value="relevance" selected="selected">relevance</option>
<option value="date">date</option>
</select>
</form>
{/exp:yboss:form}
</body>
</html>
Search Result template
But when I submit the form I’m getting “No search term submitted! search for returned no results.”
Can you explain what I’m doing wrong.
Hi bdewoody,
I played with your code; I corrected 2 lines:
1) in the line of your Search form template
<form id="search_form" action="{path="search/results"}" method="get" accept-charset="utf-8">
I corrected {path} variable to reflect path of my results template, and
2) 1) in the line of your Search form template
<option value="myfirstsite.com mysecondsite.net" selected="selected">my sites</option>
I corrected the value to reflect my domain.
After these changes the plugin woked as expected.
Question about this: Will it index text that’s hardcoded into page templates? I haven’t worked with EE’s built in search all that much (2 or 3 sites) but I remember this as being a limitation.
Many thanks!
Ed
P.S. Using your Child Categories plugin with great results. Thank you for that as well!
Laisvunas,
This plugin is fantastic! I’ve never been too happy with EE’s built in search mechanism and this is an excellent alternative. Was very easy to set up and use.
I do have a question: The site I’m working on is currently located under an IP address pending its launch. It seems like putting an IP address in the “sites” parameter will not work so I put in the client’s existing site, just to get some kind of results. Any advice about how to handle this before I’m able use their true domain name?
Here’s a testing page at the development site: http://72.47.202.196/home/testing
And here’s their OLD site that will be replaced: http://hcrs-inc.com
Regards, Ed
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.