EE: Google Mini Plugin
This plugin lets you integrate search results from your Google Mini search appliance (GM) into ExpressionEngine seamlessly. If you’re using the GM to index your web site or intranet, this plugin will handle the search requests to it, retrieve the search results in XML format, and parses them just the way you want. You don’t have to learn any XSLT, you don’t have to leave the domain of your main site, just set up a template and you’re done.
→ Download the ExpressionEngine Google Mini plugin, version 1.0
Search results
The main tag pair you will need is {exp:googlemini:results}. This contains several single variables and variable pairs that let you set up your search results page.
Parameters
host=
host="googlemini.domain.com"
The host name assigned to our Google Mini search appliance.
Request parameters
All Request Parameters used by the Google Mini search appliance are available. All Request Parameters will be overwritten by GET variables in the url. For example:
client="default_frontend" site="default_collection"
Conditional variables
if keymatch
{if keymatch}
content
{/if}
This conditional lets you display content if a KeyMatch was found for the current search.
Note: in addition to these conditionals, all single variables can be used as conditionals as well.
Single variables
| Variable | Description |
|---|---|
| {approx_results} | The estimated total number of results for the search. See also: Estimated vs. Actual Number of Results |
| {current_page} | Current page number of search results |
| {end_result} | Absolute number of the last search result being displayed |
| {keymatch_description} | KeyMatch description for current search, as indicated in your Google Mini control panel |
| {keymatch_url} | KeyMatch URL for current search, as indicated in your Google Mini control panel |
| {keywords} | Search keywords, HTML-safe |
| {keywords_raw} | Search keywords, unaltered |
| {keywords_url} | Search keywords, URL-safe |
| {next_qs} | Query string to use in a URL to the next page of search results |
| {previous_qs} | Query string to use in a URL to the previous page of search results |
| {search_url} | Complete URL used to fetch the search results from your Google Mini search appliance |
| {start_result} | Absolute number of the first search result being displayed |
| {time} | Time it took for the Google Mini to come up with the search results |
| {total_pages} | Total number of pages with search results, based on the estimated total results ({approx_results}) and the num parameter defined in the Request Parameters |
| {total_results} | The total number of search results being displayed |
| {total_synonyms} | Total number of synonyms found for current search |
Variable pairs
entries
{entries}
<div{if filtered} class="filtered"{/if}>
<h3><a href="{url}">{title}</a></h3>
<p>{excerpt}</p>
<p class="meta">{display_url}</p>
</div>
{/entries}
| Variable | Description |
|---|---|
| {cache_id} | Cache id of the found page |
| {count} | The count out of the current search results being displayed |
| {crawldate} | The date the page was indexed |
| {display_url} | Stripped down version of the found page |
| {encoding} | Character encoding of the found page |
| {excerpt} | Excerpt of the found page |
| {if filtered} | Displays content if the result was part of a parent directory |
| {language} | Language of the found page |
| {more_url} | URL to use to compose a link to a specific site or directory search using the site: syntax |
| {rank} | Rank assigned to the page by the Google Mini |
| {result_number} | Absolute result number |
| {size} | Size in KB of the found page |
| {title} | Title of the found page |
| {url} | URL of the found page |
synonyms
{synonyms}
{synonym_count}: <a href="{synonym_url}">{synonym_name}</a>
{/synonyms}
| Variable | Description |
|---|---|
| {synonym_name} | Name of the synonym found |
| {synonym_url} | Url of the synonym found |
| {synonym_count} | The count out of the current synonym being displayed |
pagination
{pagination}
{if is_active}
<strong>{page_count}</strong>
{if:else}
<a href="{path=search}{query_string}">{page_count}</a>
{/if}
{/pagination}
| Variable | Description |
|---|---|
| {if is_active} | Conditional variable to display content if current page is active |
| {page_count} | The count out of the current page being displayed |
| {query_string} | The query string used in the URL to navigate to a certain page |
Example
{exp:googlemini:results host="googlemini.domain.com" oe="utf8"}
{if keywords}
<p>Searched for <strong>{keywords}</strong><br />
Results <strong>{start_result} – {end_result}</strong> of about <strong>{approx_results}</strong>.</p>
{/if}
{if keymatch}
<p>KeyMatch: <a href="{keymatch_url}">{keymatch_description}</a></p>
{/if}
{if total_synonyms}
<h3>Also try:</h3>
<ul>
{synonyms}
<li><a href="{path=search}?q={synonym_url}">{synonym_name}</a></li>
{/synonyms}
</ul>
{/if}
{entries}
{if count == 1}<ol id="searchresults">{/if}
<li{if filtered} class="level2"{/if}>
<h3><a href="{url}">{title}</a></h3>
{if excerpt}<span class="excerpt">{excerpt}</span>{/if}
<span class="meta">{display_url}</span>
{if more_url}<span class="sitesearch">[ <a href="{path=search}?q=site:{more_url}%20{keywords_url}">More results from {more_url}</a> ]</span>{/if}
</li>
{if count == total_results}</ol>{/if}
{/entries}
{if total_pages > 1}
<p class="pagination">
<span class="count">{current_page}/{total_pages}</span>
{if previous_qs}<a class="prev" href="{path=search}{previous_qs}">Previous page</a>{/if}
{pagination}{if is_active}<strong>{page_count}</strong> {if:else}<a href="{path=search}{query_string}">{page_count}</a> {/if}{/pagination}
{if next_qs}<a class="next" href="{path=search}{next_qs}">Next page</a>{/if}
</p>
{/if}
{/exp:googlemini:results}
Keywords
To display keywords outside the results-tags, use the single tag {exp:googlemini:keywords}, for example:
<title>{exp:googlemini:keywords} - Search - My Site Name</title>
Search form
To create a search form, simply point a form to your search results template and use an input field with name="q". For example:
<form action="{path=search}" method="get">
<fieldset>
<legend>Search this site</legend>
<label for="keywords">Keywords</label>
<input type="text" name="q" id="keywords" value="{exp:googlemini:keywords}" />
<button type="submit">Search</button>
</fieldset>
</form>
Known issues
ExpressionEngine sanitizes all input data before a user (or third party developer like me) can get to it. This is great for security, but can cause a cryptic error message when the search keywords contains either of these characters: ;?() You can work around this inconvenience by cleaning the keywords with JavaScript before the form is submitted.
- 19 maart 2008, 13:28
- Add-Ons, ExpressionEngine, Searching
- 1 comment

You sir, are a god-send. This is just the plugin I’ve been looking for! This greatly simplifies my life and you’ve saved me hours upon hours of coding.