2
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'];