Count search results

Permalink 2 users found helpful
Hello everyone,

Is it possible to count the total amount of search results when using the search block ?

Like when you use yahoo.com. yahoo shows the total amount of search results to the left like this:

"43,300,000 results for
concrete5"

So far i have tried with this line of code.

<?php echo count($results); ?>


But it only counts the amount of search results on the current page.

If pagination is active, it should add the total result count on the other pages too, but it doesn't.

Please help. :)

Thank you in advance

87up
 
Mnkras replied on at Permalink Reply
Mnkras
try using this as a custom template:

<? defined('C5_EXECUTE') or die("Access Denied."); ?> 
<? if (isset($error)) { ?>
   <?=$error?><br/><br/>
<? } ?>
<form action="<?=$this->url( $resultTargetURL )?>" method="get">
   <? if( strlen($title)>0){ ?><h3><?=$title?></h3><? } ?>
   <? if(strlen($query)==0){ ?>
   <input name="search_paths[]" type="hidden" value="<?=htmlentities($baseSearchPath, ENT_COMPAT, APP_CHARSET) ?>" />
   <? } else if (is_array($_REQUEST['search_paths'])) { 
      foreach($_REQUEST['search_paths'] as $search_path){ ?>
         <input name="search_paths[]" type="hidden" value="<?=htmlentities($search_path, ENT_COMPAT, APP_CHARSET) ?>" />
   <?  }
   } ?>
   <input name="query" type="text" value="<?=htmlentities($query, ENT_COMPAT, APP_CHARSET)?>" />
   <input name="submit" type="submit" value="<?=$buttonText?>" />


i didn't try with pagination (don't feel like makin pages)

if you want to see where i put it search for
//search results text
in the code
87up replied on at Permalink Reply
87up
Hello Mnkras,

Thank you for your answer.


Well it still only counts the amount of search results on 1 page. If i got 3 pages with search results, I need those results to be included in the total result count too.

Isn't that possible ?

The core files for the search function must include an array that contains all the search results when using the search block. ?

Can anyone help me locate these core files for the search function. Maybe that could be the answer for my problem. :)

Thank you in advance.
Sinator replied on at Permalink Best Answer Reply
echo 'Total: '. $paginator->result_count;
MathiasB replied on at Permalink Reply
MathiasB
Pretty simple... Thank You!
MathiasB replied on at Permalink Reply
MathiasB
$pages = $pagination->getTotalResults();
at the top of the php.

then:

<?php echo $pages; ?>


Best Mathias