It is currently Sun Jul 05, 2009 7:20 pm (All times are UTC )

 


Forum rules

Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Search Problem
Posted: Wed Feb 07, 2007 9:54 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Mon May 15, 2006 2:50 pm
Posts: 114
If anyone has a few moments I would appreciate it they could have a look at http://www.pacemakerpressintl.com this is a site I have been building and is now LIVE, however, it has been noticed that the search is not performing quite as it should ....

1. Quick Search off the front page : Enter some phrase, eg Alan Smart
    Results show 27 images, I have already modified com_search to default to exact search

2. Click on page 2 of the results, the remaining 2 images show up as they are still being searched under the exact phrase.

Now, try this one, back to the front page, search for Keith Gillespie, 487 results.

Click on say page 7, the search returns to an "any" word search - question is Why?  and more importantly, how can I fix it!

Thanks in advance


Top
   
 
 Post subject: Re: Search Problem
Posted: Wed Feb 14, 2007 11:18 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Dec 24, 2006 1:30 pm
Posts: 5
Location: Bratislava, Slovak Republic
desk2web wrote:
I have already modified com_search to default to exact search


How exactly did you do that?

Thanks

_________________
http://www.spywarenews.net

http://www.musicworld.sk


Top
  E-mail  
 
 Post subject: Re: Search Problem
Posted: Fri Mar 23, 2007 3:36 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Mon May 15, 2006 2:50 pm
Posts: 114
Edit the search.php file in com_search:

Code:
<?php
/**
* @version $Id: search.php 3723 2006-05-29 16:14:03Z stingrey $
* @package Joomla
* @subpackage Search
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

require_once( $mainframe->getPath( 'front_html' ) );
if($_REQUEST['searchphrase']=='')
{
$_REQUEST['searchphrase']=$_GET['searchphrase']='exact';
}

// page title
$mainframe->setPageTitle( _SEARCH_TITLE );

switch ( $task ) {
   default:
      viewSearch();
      break;
}

function viewSearch() {
   global $mainframe, $mosConfig_absolute_path, $mosConfig_lang, $my;
   global $Itemid, $database, $_MAMBOTS;
   global $mosConfig_list_limit;
//$mosConfig_list_limit=50;

   $restriction = 0;
   
   // try to find search component's Itemid
   $query = "SELECT id"
      . "\n FROM #__menu"
      . "\n WHERE type = 'components'"
      . "\n AND published = 1"
      . "\n AND link = 'index.php?option=com_search'"
      ;
   $database->setQuery( $query );
   $_Itemid = $database->loadResult();

   if ($_Itemid != "") {
      $Itemid = $_Itemid;
   }

   $gid = $my->gid;

   // Adds parameter handling
   if( $Itemid > 0 && $Itemid != 99999999 ) {
      $menu = $mainframe->get( 'menu' );
      $params = new mosParameters( $menu->params );
      $params->def( 'page_title', 1 );
      $params->def( 'pageclass_sfx', '' );
      $params->def( 'header', $menu->name, _SEARCH_TITLE );
      $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
   } else {
      $params = new mosParameters('');
      $params->def( 'page_title', 1 );
      $params->def( 'pageclass_sfx', '' );
      $params->def( 'header', _SEARCH_TITLE );
      $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
   }

   // html output
   search_html::openhtml( $params );

   $searchword = strval( mosGetParam( $_REQUEST, 'searchword', '' ) );
   $searchword = $database->getEscaped( trim( $searchword ) );
   
   // limit searchword to 20 characters
   if ( strlen( $searchword ) > 20 ) {
      $searchword    = substr( $searchword, 0, 19 );
      $restriction    = 1;
   }
   
   // searchword must contain a minimum of 3 characters
   if ( $searchword && strlen( $searchword ) < 3 ) {
      $searchword    = '';
      $restriction    = 1;
   }

   $search_ignore = array();
   @include "$mosConfig_absolute_path/language/$mosConfig_lang.ignore.php";

   $orders = array();
   $orders[] = mosHTML::makeOption( 'newest', _SEARCH_NEWEST );
   $orders[] = mosHTML::makeOption( 'oldest', _SEARCH_OLDEST );
   $orders[] = mosHTML::makeOption( 'popular', _SEARCH_POPULAR );
   $orders[] = mosHTML::makeOption( 'alpha', _SEARCH_ALPHABETICAL );
   $orders[] = mosHTML::makeOption( 'category', _SEARCH_CATEGORY );
   $ordering = strtolower( strval( mosGetParam( $_REQUEST, 'ordering', 'newest') ) );
   $lists = array();
   $lists['ordering'] = mosHTML::selectList( $orders, 'ordering', 'id="search_ordering" class="inputbox"', 'value', 'text', $ordering );

   $searchphrase = strtolower( strval( mosGetParam( $_REQUEST, 'searchphrase', 'exact' ) ) );
   $searchphrases = array();

   $phrase = new stdClass();
   $phrase->value       = 'any';
   $phrase->text       = _SEARCH_ANYWORDS;
   $searchphrases[]    = $phrase;

   $phrase = new stdClass();
   $phrase->value       = 'all';
   $phrase->text       = _SEARCH_ALLWORDS;
   $searchphrases[]    = $phrase;

   $phrase = new stdClass();
   $phrase->value       = 'exact';
   $phrase->text       = _SEARCH_PHRASE;
   $searchphrases[]    = $phrase;

   $lists['searchphrase']= mosHTML::radioList( $searchphrases, 'searchphrase', '', $searchphrase );

   // html output
   search_html::searchbox( htmlspecialchars( stripslashes( $searchword ) ), $lists, $params );

   if (!$searchword) {
      if ( count( $_POST ) ) {
         // html output
         // no matches found
         search_html::message( _NOKEYWORD, $params );
      } else if ( $restriction ) {
         // html output
         search_html::message( _SEARCH_MESSAGE, $params );
      }
   } else if ( in_array( $searchword, $search_ignore ) ) {
      // html output
      search_html::message( _IGNOREKEYWORD, $params );
   } else {
      // html output      
      
      if ( $restriction ) {
         // html output
         search_html::message( _SEARCH_MESSAGE, $params );
      }
      
      $searchword_clean = htmlspecialchars( stripslashes( $searchword ) );
      
      search_html::searchintro( $searchword_clean, $params );

      mosLogSearch( $searchword );
      $phrase    = strval( mosGetParam( $_REQUEST, 'searchphrase', '' ) );
      $ordering    = strval( mosGetParam( $_REQUEST, 'ordering', '' ) );

      $_MAMBOTS->loadBotGroup( 'search' );
      $results    = $_MAMBOTS->trigger( 'onSearch', array( $searchword, $phrase, $ordering ) );
      $totalRows    = 0;

      $rows = array();
      for ($i = 0, $n = count( $results); $i < $n; $i++) {
         $rows = array_merge( (array)$rows, (array)$results[$i] );
      }

      $totalRows = count( $rows );

      for ($i=0; $i < $totalRows; $i++) {
         $text = &$rows[$i]->text;
         
         if ($phrase == 'exact') {
            $searchwords    = array($searchword);
            $needle       = $searchword;
         } else {
            $searchwords    = explode(' ', $searchword);
            $needle       = $searchwords[0];
         }
         
         $text = mosPrepareSearchContent( $text, 200, $needle );
   
           foreach ($searchwords as $hlword) {
            $text = preg_replace( '/' . preg_quote( $hlword, '/' ) . '/i', '<span class="highlight">\0</span>', $text );
         }
         
         if ( strpos( $rows[$i]->href, 'http' ) == false ) {
            $url = parse_url( $rows[$i]->href );
            parse_str( @$url['query'], $link );

            // determines Itemid for Content items where itemid has not been included
            if ( isset($rows[$i]->type) && @$link['task'] == 'view' && isset($link['id']) && !isset($link['Itemid']) ) {
               $itemid    = '';
               $_itemid = $mainframe->getItemid( $link['id'], 0 );
               
               if ($_itemid) {
                  $itemid = '&Itemid='. $_itemid;
               }
               
               $rows[$i]->href = $rows[$i]->href . $itemid;
            }
         }
      }

      $mainframe->setPageTitle( _SEARCH_TITLE );

      $total       = $totalRows;
      $limit      = intval( mosGetParam( $_GET, 'limit', $mosConfig_list_limit ) );
      $limitstart = intval( mosGetParam( $_GET, 'limitstart', 0 ) );
      
      // prepares searchword for proper display in url
      $searchword_clean = urlencode(stripslashes($searchword_clean));
      
      if ( $n ) {
      // html output
         require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
         $pageNav = new mosPageNav( $total, $limitstart, $limit );

         search_html::display( $rows, $params, $pageNav, $limitstart, $limit, $total, $totalRows, $searchword_clean );
      } else {
      // html output
         search_html::displaynoresult();
      }

      // html output
      search_html::conclusion( $searchword_clean, $pageNav );
   }

   // displays back button
   echo '<br/>';
   mosHTML::BackButton ( $params, 0 );
}

function mosLogSearch( $search_term ) {
   global $database;
   global $mosConfig_enable_log_searches;

   if ( @$mosConfig_enable_log_searches ) {
      $query = "SELECT hits"
      . "\n FROM #__core_log_searches"
      . "\n WHERE LOWER( search_term ) = '$search_term'"
      ;
      $database->setQuery( $query );
      $hits = intval( $database->loadResult() );
      if ( $hits ) {
         $query = "UPDATE #__core_log_searches"
         . "\n SET hits = ( hits + 1 )"
         . "\n WHERE LOWER( search_term ) = '$search_term'"
         ;
         $database->setQuery( $query );
         $database->query();
      } else {
         $query = "INSERT INTO #__core_log_searches VALUES ( '$search_term', 1 )"
         ;
         $database->setQuery( $query );
         $database->query();
      }
   }
}
?>


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

Quick reply

 



Who is online

Users browsing this forum: jackoneil and 68 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group