1
nmshah
Changing the search function in xoops site
  • 2007/12/7 10:14

  • nmshah

  • Just can't stay away

  • Posts: 556

  • Since: 2007/7/2 8


In my site when a search is made it shows results from all the installed modules. I want the search to exclude certain modules like isearch, tags, mp manager etc. How should i do this?

2
terrion
Re: Changing the search function in xoops site
  • 2007/12/7 10:35

  • terrion

  • Friend of XOOPS

  • Posts: 299

  • Since: 2004/9/19


I had the exact opposite problem. When a user searched it only searched within the module they were in. I found an if/then statement in the search block that I deleted that made it so I searched all modules.

The origional block looked like this:

Quote:





<{if $block.modid > 1}>

<{/if}>




I modified that to be

Quote:

You might be able to do something like in the first quote above and have nested if statements for each module number you want to exclude.
Terrion
Purchase, renew, or transfer your domain name to Ultranet Domains and get a FREE 10GB hosting account. Virtual Dedicated Servers around $35/monthly, no contract. FREE 24/7 telephone ...

3
wizanda
Re: Changing the search function in xoops site
  • 2007/12/7 10:58

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


In each modules xoops_version.php
/*
$modversion['hasSearch'] = 1; <<----0
$modversion['search']['file'] = "include/search.php";
$modversion['search']['func'] = "search";
*/

You can miss that bit and update it, then search function will be removed from each module or just sticking a 0 will switch it off.....

4
nmshah
Re: Changing the search function in xoops site
  • 2007/12/7 11:56

  • nmshah

  • Just can't stay away

  • Posts: 556

  • Since: 2007/7/2 8


Thanks a lot, just what i required.

5
JBzh
Re: Changing the search function in xoops site
  • 2008/1/31 9:57

  • JBzh

  • Just popping in

  • Posts: 18

  • Since: 2004/4/26


I had the same situation as nmshah, and at first I thought I could set the hasSearch parameter to 0.
But after I did that the iSearch module stopped reccording the searches keywords.
I set hasSearch to 1 or 0 few times and updated the module each time to be sure.


So I supposed iSearch records keywords when called from search.php here :
$results =& $module->search($queries$andor50);

I changed it to :
// Here is the only line I added beside the close bracket of course :
if ( $module->getVar('name') != _MI_ISEARCH_NAME ) {
    
$results =& $module->search($queries$andor50);
    echo 
"

".$module->getVar('name')."

"
;  // => here is what I wanted to remove.
    
$count count($results);
    if (!
is_array($results) || $count == 0) {
    echo 
"

"._SR_NOMATCH."

"
// => That too
    
} else {
        for (
$i 0$i $count$i++) {
            
// => And every echo below too
            
if (isset($results[$i]['image']) && $results[$i]['image'] != "") {
                echo 
".$module->getVar('dirname')."/".$results[$i]['image']."' alt='".$module->getVar('name')."' /> ";
            } else {
                echo 
")."' width='26' height='26' /> ";
            }
            echo 
".$module->getVar('dirname')."/".$results[$i]['link']."'>".$myts->makeTboxData4Show($results[$i]['title'])."n";
            echo 
"";
            
$results[$i]['uid'] = intval($results[$i]['uid']);
            if ( !empty(
$results[$i]['uid']) ) {
                
$uname XoopsUser::getUnameFromId($results[$i]['uid']);
                echo 
"  .XOOPS_URL."/userinfo.php?uid=".$results[$i]['uid']."'>".$uname."n";
            }
            echo 
$results[$i]['time'] ? " ("formatTimestamp(intval($results[$i]['time'])).")" "";
            echo 
"
n"
;
        }
        if ( 
$count == ) {
            
$search_url XOOPS_URL.'/search.php?query='.urlencode(stripslashes(implode(' '$queries)));
            
$search_url .= "&mid=$mid&action=showall&andor=$andor";
            echo 
'.$search_url.'">'._SR_SHOWALLR.'

'
;
        }
    }
    unset(
$results);
    unset(
$module);
//here is the close bracket :
}

Then I set hasSearch parameters to 1 and updated the module.

Well, iSearch still records the searches keywords. So I was wrong, iSearch doesn't record keywords when called here.
But now an iSearch part in the search results page is no longer displayed, which was what I wanted.
I don't know what $results =& $module->search($queries, $andor, 5, 0); does, so I placed the test just after it :
$results =& $module->search($queries$andor50);
if ( 
$module->getVar('name') != _MI_ISEARCH_NAME ) {
    echo 
"

".$module->getVar('name')."

"
;  // => here is what I wanted to remove.
    
$count count($results);
    if (!
is_array($results) || $count == 0) {
    echo 
"

"._SR_NOMATCH."

"
// => That too
    
} else {
        for (
$i 0$i $count$i++) {
            
// => And every echo below too
            
if (isset($results[$i]['image']) && $results[$i]['image'] != "") {
                echo 
".$module->getVar('dirname')."/".$results[$i]['image']."' alt='".$module->getVar('name')."' /> ";
            } else {
                echo 
")."' width='26' height='26' /> ";
            }
            echo 
".$module->getVar('dirname')."/".$results[$i]['link']."'>".$myts->makeTboxData4Show($results[$i]['title'])."n";
            echo 
"";
            
$results[$i]['uid'] = intval($results[$i]['uid']);
            if ( !empty(
$results[$i]['uid']) ) {
                
$uname XoopsUser::getUnameFromId($results[$i]['uid']);
                echo 
"  .XOOPS_URL."/userinfo.php?uid=".$results[$i]['uid']."'>".$uname."n";
            }
            echo 
$results[$i]['time'] ? " ("formatTimestamp(intval($results[$i]['time'])).")" "";
            echo 
"
n"
;
        }
        if ( 
$count == ) {
            
$search_url XOOPS_URL.'/search.php?query='.urlencode(stripslashes(implode(' '$queries)));
            
$search_url .= "&mid=$mid&action=showall&andor=$andor";
            echo 
'.$search_url.'">'._SR_SHOWALLR.'

'
;
        }
    }
    unset(
$results);
    unset(
$module);
}


I don't like the way I changed search.php code, if anyone sees a better method I would appreciate :)

I did worse then : I wanted to remove the iSearch checkbox in advanced search form ("Search in" list).
Couldn't find something else, so in the class/xoopsform/formcheckbox.php :
foreach ( $this->getOptions() as $value => $name ) {
    if ( 
$name != _MI_ISEARCH_NAME ) {
        
$ret .= ".$this->getName()."' value='".$value."'";
        if (
count($this->getValue()) > && in_array($value$this->getValue())) {
            
$ret .= " checked='checked'";
        }
        
$ret .= $this->getExtra()." />".$name."n";
    }
}
return 
$ret;


I am still looking to find where iSearch is called, where the code which records the keywords searched is.

Login

Who's Online

341 user(s) are online (249 user(s) are browsing Support Forums)


Members: 0


Guests: 341


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits