Support Forums

Allow Extra fields to be searched!

This is a discussion on Allow Extra fields to be searched! within the Modules / Plugins / Modifications forums, part of the Developer Forums category; Hi all After hacking the Listings.php I have managed to get the extra fields included in searches, and it respects ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 02-11-2009, 09:12 AM   #1
Member
 
marketingsolutions's Avatar
 
Join Date: Sep 2006
Location: Ilfracombe - England
Posts: 59
Rep Power: 22
marketingsolutions is on a distinguished road
Default Allow Extra fields to be searched!

Hi all

After hacking the Listings.php I have managed to get the extra fields included in searches, and it respects fSearch values

WORKING WITH: includes/classes/kernel/Listings.php

Save a backup of Listings.php as Listings.php.old or whatever ( we should ALWAYS backup!)
Open Listings.php in your favourite editor
scroll to line 439 ( it should be a commented out echo )
replace line 439 with the following code

PHP Code:
################################################## ######
# Allow Extra Fields to be searchable
# BKD - 11/02/2009
################################################## ######
if(!defined('IN_ADMIN') && !isset($_GET['cat'])){
    
$efsql "SELECT p.pID FROM ".PREFIX."products_fields AS p RIGHT JOIN ".PREFIX."fields AS f ON p.fID = f.fID WHERE f.fSearch = 'Y' AND (";
    
    
$efq trim(mysql_real_escape_string($_REQUEST['searchtext']));
    
$efq_array explode(" ",$efq);
    foreach(
$efq_array as $idx => $searchvalue){
        
$efsql .= " p.sValue LIKE '%$searchvalue%' OR";
    }
    
$efsql rtrim($efsql,' OR');
    
$efsql .= ')';
    
$efqresults $db->query($efsql);
    
$efnumrows $efqresults->size();
    if(
$efnumrows != 0){
        
$efqrows = array();
        
$ef_addon_sql '';
        while(
$row $efqresults->fetch()){
            
$efqrows[] = $row;
        }
        foreach(
$efqrows as $idx => $extrafieldid){
            
$pid $extrafieldid['pID'];
            
$ef_addon_sql .= "SELECT p.id, p.owner, p.title, p.featured, p.section, p.shortDescription, p.description, p.price, p.dateadded, p.expiration, p.display, p.pHighlighted, p.pBold, p.hitcount, p.url, u.username, u.state, u.city, u.country, u.extra, u.extra2, u.extra3 "$select ." FROM ".PREFIX."listings AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id WHERE p.id = '$pid' UNION ";
        }
    }
    if(
$ef_addon_sql ''){
        
$listingSQL $ef_addon_sql.$listingSQL;
    }
}
################################################### ###### 
Now save Listings.php and upload to your server.

Et Voila! Your extra fields ( if they set as searchable in the admin ) should now be included in subsequent searches.

If you have any problems with this solution, please email me with details of your problem and i will try to help you out My email is [email protected].

Ben Duffin

Last edited by marketingsolutions; 03-03-2009 at 06:21 AM. Reason: Added Additional conditions - was listing all listings in any category
marketingsolutions is offline   Reply With Quote
Old 02-11-2009, 09:29 AM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

This is very cool. Thanks for sharing!
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-11-2009, 09:39 AM   #3
Member
 
marketingsolutions's Avatar
 
Join Date: Sep 2006
Location: Ilfracombe - England
Posts: 59
Rep Power: 22
marketingsolutions is on a distinguished road
Default PHP Support

Edited away

Last edited by marketingsolutions; 02-11-2009 at 10:07 AM. Reason: personal details included
marketingsolutions is offline   Reply With Quote
Old 02-11-2009, 09:54 AM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

I like this so much I am converting it to a module. But it needs a new hook in place. So it will be ready with the next release. Would you like me to send you the files?
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-12-2009, 09:03 AM   #5
Junior Member
 
 
Join Date: Feb 2009
Posts: 16
Rep Power: 11
Freddy is on a distinguished road
Default

Oooo I just came into the forums to find an answer to my problem and this might be it!

I purchased the search module here:

ClassifiedMods Search Module

Works a treat but I need an additional field (well a radio select option). Are there any other avenues around for adding another search option?

Will I have to have the developers 68 code for including this script (I have designers)?

Big thanks to marketingsolutions for posting this up!

Cheers,
Fred
Freddy is offline   Reply With Quote
Old 02-12-2009, 10:09 AM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

With this code it would require the Developer edition. I have taken this and added it a module but it needed a new hook added. So it would not be in a module form until the next release.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 02-12-2009, 10:18 AM   #7
Junior Member
 
 
Join Date: Feb 2009
Posts: 16
Rep Power: 11
Freddy is on a distinguished road
Default

Ah bugger. Will have to upgrade then just for this extra field to appear in search box :/

SO just to confirm, this kind script from the OP will allow me to add another search field to my search box?

Many thanks,
Fred
Freddy is offline   Reply With Quote
Old 03-12-2009, 03:16 AM   #8
Customer
 
hel68c's Avatar
 
Join Date: Jun 2008
Location: Canada, Quebec
Posts: 289
Rep Power: 22
hel68c is just really nice hel68c is just really nice
Default

Can we used it on version 4.08?
__________________
Serge
HobbyClassified.com
V4.08 Developper, Module installed (CIV Scam Filter, Maffo Location System, Maffo News,Youtube, Seller Store)
hel68c is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
extra fields redstar Technical Support 2 11-17-2008 10:36 AM


All times are GMT -4. The time now is 02:36 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0