I've also tried "Faceted Search Through PostHooks". The problem is that I get two sets of results on the results page.
When I search for a word that appears in the content, I get two identical lists underneath each other.
When I search for an item no (where the item no doesn't appear in the content but it is in the database) the results page shows this:
There were no search results for the search
"ABC123456". Please try using more general terms to
get more results.
1. ABC123456
So now I know it can search the database but the double search results are confusing. Is there a way to not show the first result when there's an item no result?
Here's my SearchForm call
[[!SimpleSearchForm? &tpl=`MySearchForm` &landing=`42`]]
On the Search Results page
[[!SimpleSearch? &postHooks=`ItemnoFacetHook` &tplitemno=`MySearchResult`]]
[[+sisea.results]]
<br /><br />
[[+sisea.itemno.results]]
ItemnoFacetHook snippet
<?php
$path = MODX_CORE_PATH . 'components/aeibbproducts/';
$result = $modx->addPackage('aeibbproducts',$path .
'model/','aei_');
if (! $result) {
return 'failed to add package';
}
$c = $modx->newQuery('BbProducts');
$c->where(array('aei' => $search));
$product = $modx->getObject('BbProducts', $c);
$results = array();
if ($product) {
$results[] = array(
'pagetitle' => $product->get('aei'),
'longtitle' => $product->get('sim')
);
}
$hook->addFacet('itemno',$results);
return true;
MySearchForm chunk
<form class="sisea-search-form" action="[[~[[+landing]]]]" method="[[+method]]">
<fieldset>
<input type="text" name="[[+searchIndex]]" id="[[+searchIndex]]" value="[[+searchValue]]" />
<input type="hidden" name="id" value="[[+landing]]" />
<input type="submit" value="[[%sisea.search? &namespace=`sisea` &topic=`default`]]" />
</fieldset>
</form>
MySearchResult chunk
<div class="sisea-result">
<h3>[[+idx]]. <a href="[[~30? &prodNum=`[[+pagetitle]]` &simCode=`[[+longtitle]]`]]" title="[[+pagetitle]]">[[+pagetitle]]</a></h3>
</div>
Thanks in advance for all the help!