highlighted the FOUND X RESULTS sentence

This commit is contained in:
Bachir Soussi Chiadmi 2014-07-02 18:21:39 +02:00
parent 9df43555ac
commit 5b26e36355
3 changed files with 67 additions and 42 deletions

View File

@ -763,43 +763,58 @@ function template_preprocess_materio_search_api_select_viewmode_block(&$vars){
* *
* @see materio-search-api-results.tpl.php * @see materio-search-api-results.tpl.php
*/ */
function template_preprocess_materio_search_api_results(array &$variables) { function template_preprocess_materio_search_api_results(array &$vars) {
// dsm($variables, '$variables'); // dsm($vars, '$vars');
$results = $variables['results']; $results = $vars['results'];
$keys = $variables['keys']; $keys = $vars['keys'];
// $variables['items'] = $variables['index']->loadItems(array_keys($variables['results']['results'])); // $vars['items'] = $vars['index']->loadItems(array_keys($vars['results']['results']));
$variables['result_count'] = $results['result count']; $vars['result_count'] = $results['result count'];
$variables['sec'] = round($results['performance']['complete'], 3); $vars['sec'] = round($results['performance']['complete'], 3);
$vars['keywords'] = implode(', ', $vars['keys']);
if(isset($results['breves count'])){ if(isset($results['breves count'])){
$variables['search_performance'] = format_plural( $vars['perfascard'] = true;
$vars['search_performance'] = format_plural(
$results['breves count'], $results['breves count'],
'The search found 1 news ', 'The search found 1 news ',
'The search found @count news ' 'The search found @count news '
); );
$variables['search_performance'] .= format_plural( $vars['search_performance'] .= format_plural(
$variables['result_count'] - $results['breves count'], $vars['result_count'] - $results['breves count'],
'with 1 associated matter.', 'with 1 associated matter.',
'with @count associated matters.' 'with @count associated matters.'
); );
$variables['search_performance'] .= format_plural( $vars['search_performance'] .= format_plural(
$results['could results']['result count'], $results['could results']['result count'],
' You could find 1 result with a ', ' You could find 1 result with a ',
' You could find <strong>@count results</strong> with a ' ' You could find <strong>@count results</strong> with a '
); );
$variables['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187'); $vars['search_performance'] .= l(t('full access to materiO\'.'), 'node/11187');
$vars['search_performance'] .= l(t('pricing'), 'node/11187', array("attributes"=>array("class"=>array('button'))));
}else{ }else{
$variables['search_performance'] = format_plural( $vars['perfascard'] = false;
// $results['result count'],
$variables['result_count'], // $vars['search_performance'] = format_plural(
'The search found 1 result.', // // $results['result count'],
'The search found @count results.' // $vars['result_count'],
// 'The search found 1 result ',
// 'The search found @count results '
// )
$vars['search_performance'] = t('The search found @count result(s) with keywords @keys. @mat materials and @new news.', array(
"@count"=>$vars['result_count'],
"@keys"=>$vars['keywords'],
"@mat"=>4,
"@new"=>7)
); );
} }
//dsm($variables, 'variables'); //dsm($vars, '$vars');
} }

View File

@ -38,9 +38,19 @@
<?php //if (!empty($result_count)) : ?> <?php //if (!empty($result_count)) : ?>
<div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>"> <div class="materiobase-results <?php print ' view-mode-' . $variables['view_mode'];?>">
<?php if ($result_count) : ?> <?php if ($result_count) : ?>
<p class="search-performance"><?php print render($search_performance); ?></p> <?php if(!$perfascard): ?>
<p class="search-performance"><?php print render($search_performance); ?></P>
<?php endif; ?>
<?php //print render($spellcheck); ?> <?php //print render($spellcheck); ?>
<div class="search-results"> <div class="search-results">
<?php if($perfascard): ?>
<article class="search-performance <?php print ' view-mode-' . $variables['view_mode'];?>">
<div class="inner">
<p><?php print render($search_performance); ?></P>
</div>
</article>
<?php endif; ?>
<?php //dsm($items, '$items'); ?> <?php //dsm($items, '$items'); ?>
<?php <?php
// TODO: use cache system to gain in speed, view http://drupal.org/node/930760 // TODO: use cache system to gain in speed, view http://drupal.org/node/930760