Skip to content

Commit

Permalink
Add outputSeparator option
Browse files Browse the repository at this point in the history
I don’t like adding a conditional to each for loop, so open to
suggestions
  • Loading branch information
jpdevries committed Jan 20, 2014
1 parent e3319c9 commit 0f82536
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions core/components/simplesearch/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ SimpleSearch 1.8.0
- Added support to ElasticSearch driver for using search fields
- Added support to ElasticSearch driver for boosting results by a field value
- Updated Elastica to v0.90.7.0
========================================================================
- [#84] Czech localization
- [#78] Japanese localization
- [#77] Enable $tvPrefix to prefix TV placeholders
- [#2] Do not search TV values if includeTVs != 1 (modxcms/SimpleSearch#2)
- [#1] Fixed SQL for "exclude" parameter (modxcms/SimpleSearch#1)
- Added driver for ElasticSearch
- Added support to ElasticSearch driver for using search fields
- Added support to ElasticSearch driver for boosting results by a field value
- Updated Elastica to v0.90.7.0
- Added outputSeparator option

SimpleSearch 1.7.0
========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@
$activeFacet = $modx->getOption('facet',$_REQUEST,$modx->getOption('activeFacet',$scriptProperties,'default'));
$activeFacet = $modx->sanitizeString($activeFacet);
$facetLimit = $modx->getOption('facetLimit',$scriptProperties,5);
$outputSeparator = $modx->getOption('outputSeparator',$scriptProperties,"\n");

/* get results */
$response = $search->getSearchResults($searchString,$scriptProperties);
$placeholders = array('query' => $searchString);
$resultsTpl = array('default' => array('results' => array(),'total' => $response['total']));
if (!empty($response['results'])) {
/* iterate through search results */
$total = count($response['results']);
foreach ($response['results'] as $resourceArray) {
$resourceArray['idx'] = $idx;
if (empty($resourceArray['link'])) {
Expand All @@ -97,7 +99,7 @@
$extract = str_replace(array('[[',']]'),'',$extract);
$resourceArray['extract'] = !empty($highlightResults) ? $search->addHighlighting($extract,$highlightClass,$highlightTag) : $extract;
}
$resultsTpl['default']['results'][] = $search->getChunk($tpl,$resourceArray);
$resultsTpl['default']['results'][] = $search->getChunk($tpl,$resourceArray) . (($total > $idx) ? $outputSeparator : "");

This comment has been minimized.

Copy link
@jpdevries

jpdevries Jan 20, 2014

Author

@theboxer one thing I don't like about this approach is the ternary on each iteration. what do you think?

$idx++;
}
}
Expand Down Expand Up @@ -127,7 +129,7 @@
foreach ($facetResults['results'] as $r) {
$r['idx'] = $idx;
$fTpl = !empty($scriptProperties['tpl'.$facetKey]) ? $scriptProperties['tpl'.$facetKey] : $tpl;
$resultsTpl[$facetKey]['results'][] = $search->getChunk($fTpl,$r);
$resultsTpl[$facetKey]['results'][] = $search->getChunk($fTpl,$r) . (($facetResults['total'] > $idx) ? $outputSeparator : "");
$idx++;
}
}
Expand Down

0 comments on commit 0f82536

Please sign in to comment.