Aliases causing duplicate search results

Permalink
Hello all,

I have what is hopefully a fairly simple problem. When I have an aliased page, both the original page and the alias are showing up in search results, causing a rather undesirable duplicate. I can't find any other mention of this in the forum, so I am assuming the problem is on my end. Anyone know what might have happened? Let me know if I haven't supplied enough info.

Thanks very much,
Isaac

 
somenboll replied on at Permalink Reply
Any word on this? Have the same problem!!
mesuva replied on at Permalink Reply
mesuva
I got around this by sort of filtering the output on an overridden view for the search block. I simply keep track of what page ids have been output using an array and check against this array before outputting a further search result.

I created the folder 'search' in the top level blocks folder, and into that copied view.php from /concrete/blocks/search/. (The normal way to override the output of a block).

I only added a few lines of code. The following replaces lines 23 to 40:

<?php  
$tt = Loader::helper('text');
if ($do_search) {
   if(count($results)==0){ ?>
      <h4 style="margin-top:32px"><?php echo t('There were no results found. Please try another keyword or phrase.')?></h4>   
   <?php  }else{ 
      $pageIDsListed = array();
      ?>
      <div id="searchResults">
      <?php  foreach($results as $r) { 
         $id = $r->getID(); // get the page id
         if (!in_array($id, $pageIDsListed)) {  // if the pageid hasn't already been shown
            $currentPageBody = $this->controller->highlightedExtendedMarkup($r->getBodyContent(), $query);?>
            <div class="searchResult">
               <h3><a href="<?php echo $r->getPath()?>"><?php echo $r->getName()?></a></h3>


Maybe that is useful to someone.
rbnz replied on at Permalink Reply
rbnz
Thanks. You've just allowed me to have a good nights sleep.

re-arranged your code so it works with extended_search add-on just fine. :)

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.