1
sorpresina
Search in sections module
  • 2004/12/10 9:27

  • sorpresina

  • Just popping in

  • Posts: 4

  • Since: 2004/12/10


I need instructions to have the XOOPS search working also in sections module

2
sorpresina
Re: Search in sections module
  • 2004/12/10 9:35

  • sorpresina

  • Just popping in

  • Posts: 4

  • Since: 2004/12/10


I found this but in the search results
there is nothing in sections module
i.e
SECTIONS
"No Match Found for your Query"


probably some parameter must be changed


1.
in sql/mysql.sql (definition of tables)
we put information in which field we will search
ex. FULLTEXT KEY `search` (``, ... ,``)

(in section: FULLTEXT KEY `search` (`title`,`content`) )

Quote:
#
# Table structure for table `seccont`
#

CREATE TABLE seccont (
artid int(11) NOT NULL auto_increment,
secid int(11) NOT NULL default '0',
title text NOT NULL,
content text NOT NULL,
counter int(11) NOT NULL default '0',
PRIMARY KEY (artid),
KEY idxseccontsecid (secid),
KEY idxseccontcounterdesc (counter),
FULLTEXT KEY `search` (`title`,`content`)
) TYPE=MyISAM;
# --------------------------------------------------------




2. xoopsversion.php

we add fields :
Quote:

// Search
$modversion['hasSearch'] = 1;
$modversion['search']['file'] = "include/search.inc.php";
$modversion['search']['func'] = "sections_search";



$modversion['search']['file'] = "include/search.inc.php"; -> decribe file in which we have definied search function.
$modversion['search']['func'] = "sections_search"; -> and name of our function.

3. a little bit difficult
search function.
Quote:

function sections_search($queryarray, $andor, $limit, $offset, $userid){
global $xoopsDB;

$sql = "SELECT artid,title FROM ".$xoopsDB->prefix("seccont") ." WHERE ";

// because count() returns 1 even if a supplied variable
// is not an array, we must check if $querryarray is really an array
if ( is_array($queryarray) && $count = count($queryarray) ) {
$sql .= "((content LIKE '%$queryarray[0]%' OR title LIKE '%$queryarray[0]%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "(content LIKE '%$queryarray[$i]%' OR title LIKE '%$queryarray[$i]%')";
}
$sql .= ") ";
}
$sql .= "ORDER BY secid DESC";
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = "images/forum.gif";
$ret[$i]['link'] = "index.php?op=viewarticle&artid=".$myrow['artid']."";
$ret[$i]['title'] = $myrow['title'];
// $ret[$i]['time'] = $myrow['created'];
// $ret[$i]['uid'] = $myrow['uid'];
$i++;
}
return $ret;
}


my english isn't good so for me is also difficult to explain

in sql question important is
$sql .= "(( LIKE '%$queryarray[0]%' OR ... OR LIKE '%$queryarray[0]%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "( LIKE '%$queryarray[$i]%' OR ... OR title LIKE '%$queryarray[$i]%')";

and formating results:
Quote:

$ret[$i]['image'] = (image);
$ret[$i]['link'] = (link);
$ret[$i]['title'] =(title);
// i don't use fields 'time' and 'uid' in section's example
// $ret[$i]['time'] = $myrow['created'];
// $ret[$i]['uid'] = $myrow['uid'];

3
sorpresina
Re: Search in sections module
  • 2004/12/10 10:04

  • sorpresina

  • Just popping in

  • Posts: 4

  • Since: 2004/12/10


I'v solved the problem
following pervious instructions
then updated the module
exit from XOOPS
and enter again

Login

Who's Online

361 user(s) are online (237 user(s) are browsing Support Forums)


Members: 0


Guests: 361


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