1
jlm69
how to list categories in search
  • 2003/11/10 14:26

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


I am using the mod xdirectory and if I have a category called Carpentry, and I do a site search for Carpentry, I get nothing back unless the word carpentry appears in the description of a listing. Is there any way to make the category (Carpentry) get listed when doing a search?

Thanks.

2
jlm69
Re: how to list categories in search
  • 2003/11/10 22:44

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


I want to have category names show up when you do a site search. Any ideas.

Thanks in advance

3
builderb
Re: how to list categories in search
  • 2003/11/10 23:33

  • builderb

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/8/4 2


I have a solution for you but I don't know if it's exactly what your looking for.

In this file: modules/xdirectory/include/search.inc.php contains the SQL statement that XOOPS uses for searches. I've added the category title but when it does a search it lists every result as a category name and not the name of the actual busines.

see my example here and tell me if that is what you're looking for. http://www.folsomliving.com
If it is I'll send you the code.

-Builderb

4
jlm69
Re: how to list categories in search
  • 2003/11/11 2:19

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


Thanks,

I'm very interested, right now I return nothing with the search.

By the way your site looks real good, nice work. I saw it a while ago and it is filling up nice, hope I have that happen for me.

5
builderb
Re: how to list categories in search
  • 2003/11/11 5:10

  • builderb

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/8/4 2


Thanks for the compliment! I'm also a member of the local chamber of commerce which helps generate interest in the our site.

anyway here's the code that searches the categories:
[quote]
// $Id: search.inc.php,v 1.6 2003/03/25 11:08:22 buennagel Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author(Hacker): Adam Frick //
// Purpose: Phonebook-like business directory //
// email: africk69@yahoo.com //
// All files of xDirectory are based on the MyLinks module, customized //
// to accomodate additional business listing information //
// ------------------------------------------------------------------------ //

function xdir_search($queryarray, $andor, $limit, $offset, $userid){
global $xoopsDB;
$sql = "SELECT l.lid,l.cid,l.title,l.submitter,l.date,c.title,t.description FROM ".$xoopsDB->prefix("xdir_links")." l LEFT JOIN ".$xoopsDB->prefix("xdir_cat")." c ON c.cid=l.cid LEFT JOIN ".$xoopsDB->prefix("xdir_text")." t ON t.lid=l.lid WHERE status>0";
if ( $userid != 0 ) {
$sql .= " AND l.submitter=".$userid." ";
}
// 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 .= " AND ((l.title LIKE '%$queryarray[0]%' OR c.title LIKE '%$queryarray[0]%' OR t.description LIKE '%$queryarray[0]%')";
for($i=1;$i<$count;$i++){
$sql .= " $andor ";
$sql .= "(l.title LIKE '%$queryarray[$i]%' OR c.title LIKE '%$queryarray[0]%' OR t.description LIKE '%$queryarray[$i]%')";
}
$sql .= ") ";
}
$sql .= "ORDER BY l.date DESC";
$result = $xoopsDB->query($sql,$limit,$offset);
$ret = array();
$i = 0;
while($myrow = $xoopsDB->fetchArray($result)){
$ret[$i]['image'] = "images/home.gif";
$ret[$i]['link'] = "singlelink.php?cid=".$myrow['cid']."&lid=".$myrow['lid']."";
$ret[$i]['title'] = $myrow['title'];
$ret[$i]['time'] = $myrow['date'];
$ret[$i]['uid'] = $myrow['submitter'];
$i++;
}
return $ret;
}
?>
quote]

You can replace the contents of this file /modules/xdirectory/include/search.inc.php
with the code here.

good luck
-B


6
jlm69
Re: how to list categories in search
  • 2003/11/12 18:41

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


Thanks alot, I thought it worked once, then I was doing other stuff with the site and when I tried it later it didn't work,
not sure if I used a category with the same key word as in the description, or if it really worked. But now it doesn't work. I changed it back to original, made changes again and still won't work. Just curious but could that change be made in the file:

search.php

Thanks again

7
builderb
Re: how to list categories in search
  • 2003/11/13 5:22

  • builderb

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/8/4 2


The file should be named: search.inc.php
and it should reside in this directory: /modules/xdirectory/include/

You shouldn't have to touch the main search file located in the root.(/search.php)

Let me know if you still have problems.

-b

8
jlm69
Re: how to list categories in search
  • 2003/11/13 12:12

  • jlm69

  • Module Developer

  • Posts: 719

  • Since: 2002/7/19


It does work , I was using a category that had no listings in it so it brought back nothing. I was thinking if there were sub categories, that would count as something, and return something. But It works if there is a listing in the category.
Thanks.

9
jayjay
Re: how to list categories in search
  • 2004/7/8 12:26

  • jayjay

  • Not too shy to talk

  • Posts: 175

  • Since: 2003/9/10


Hi to all xdirectory fans!

I found a very easy fix to the search problem in xdirectory. Builderb mentions that with the 'new' search code you can only view the category names and not the name of the business when you search the module.

This trick fixes the problem:

In include/search.inc.php on line 36 move the "c.title" part to the beginning of the sql string (just after the word SELECT that is).

Now you'll see the name of the business instead of the name of the category in search.

Thanks for a wonderful module, builderb!

Greets

Jay Jay

Login

Who's Online

333 user(s) are online (289 user(s) are browsing Support Forums)


Members: 0


Guests: 333


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