I've just installed the SimpleSearch add-on and would like to customize the search form to fit with the style of my site.
Here is my call to show the form:
<div class="topbar">[[!SimpleSearchForm? &tpl='MySimpleSearch' &landing='213' ]]</div>
The tpl chunk code: (this is currently just the default one provided in the documentation.
<form id="my_id" action="[[~[[+landing:default=`[[*id]]`]]]]" method="[[+method:default=`get`]]">
<input id="searchField" class="my_class" type="text" name="my_custom_search_field" value="[[+searchValue:default=`Search the site`]]"/>
<input id="searchIcon" class="utilityButton" type="image" alt="Search" src="/assets/templates/my/images/searchButton.png">
<input type="hidden" name="id" value="[[+landing:default=[[*id]]]]" />
</form>
The snippet SimpleSearchForm:
require_once $modx->getOption('sisea.core_path',null,$modx->getOption('core_path').'components/simplesearch/').'model/simplesearch/simplesearch.class.php';
$search = new SimpleSearch($modx,$scriptProperties);
/* setup default options */
$scriptProperties = array_merge(array(
'tpl' => 'SearchForm'
'method' => 'get',
'searchIndex' => 'search',
'toPlaceholder' => false,
'landing' => $modx->resource->get('id'),
), $scriptProperties);
if (empty($scriptProperties['landing'])) {
$scriptProperties['landing'] = $modx->resource->get('id');
}
/* if get value already exists, set it as default */
$searchValue = isset($_REQUEST[$scriptProperties['searchIndex']]) ? $_REQUEST[$scriptProperties['searchIndex']] : '';
$searchValues = explode(' ', $searchValue);
array_map(array($modx, 'sanitizeString'), $searchValues);
$searchValue = implode(' ', $searchValues);
$placeholders = array(
'method' => $scriptProperties['method'],
'landing' => $scriptProperties['landing'],
'searchValue' => strip_tags(str_replace(array('[',']','"',"'"),array('[',']','"','''),$searchValue)),
'searchIndex' => $scriptProperties['searchIndex'],
);
$output = $search->getChunk($scriptProperties['tpl'],$placeholders);
return $search->output($output,$scriptProperties['toPlaceholder']);
With that code - no search box appears. Yet with the &tpl argument removed it works again.
Am I overlooking something here or is there something else I need to do?
Thanks
Dan