View Full Version : Search by location field
Howdy,
I have requested that vB add the ability to search by the location field since 1.x. It would be a great help to my board if users could locate others in their area.
I've been told that this can be done, but it has never been described as a hack as far as I know.
I would greatly appreciate any help with this.
Thanks,
Rick Horwitz
Admin
11-21-2001, 07:53 AM
Ok this is an easy one. :)
In memberlistsearch template, add this:
<tr>
<td bgcolor="{firstaltcolor}"><normalfont><b>and Location contains</b></normalfont></td>
<td bgcolor="{firstaltcolor}"><normalfont><input type="text" class="bginput" size="35" name="location" value=""></normalfont></td>
</tr>
right after this:
</tr>
<tr>
<td bgcolor="{secondaltcolor}"><normalfont><b>and homepage contains</b></normalfont></td>
<td bgcolor="{secondaltcolor}"><normalfont><input type="text" class="bginput" size="35" name="homepage" value=""></normalfont></td>
</tr>
Now in memberlist.php, add this:
if ($location!="") {
$condition.=" AND userfield.field2 LIKE '%".addslashes($location)."%' ";
}
right after this:
if ($homepage!="") {
$condition.=" AND homepage LIKE '%".addslashes($homepage)."%' ";
}
(if the ID of your location field isn't 2, change it in the code you add)
https://vborg.vbsupport.ru/ Thank you so much! I really appreciate your help!https://vborg.vbsupport.ru/
One more request please...
I would also like to be able to send mass e-mails by location search crireria. There are a lot of options for sorting e-mail addresses for the mass mailing, but location is not one of them.
Thanks again,
Rick
Admin
11-22-2001, 11:55 AM
Ok, this is a bit more complicated.
In email.php (admin folder), add this:
if ($location!="") {
$condition.=" AND INSTR(field2,'".addslashes($location)."')>0";
}
after this:
if ($usertitle!="") {
$condition.=" AND INSTR(usertitle,'".addslashes($usertitle)."')>0";
}
(Note: this appears *twice*)
Now replace this:
$counter = $DB_site->query_first("SELECT COUNT(*) AS total FROM user WHERE $condition AND adminemail=1");
with this:
$counter = $DB_site->query_first("SELECT COUNT(*) AS total FROM user,userfield WHERE user.userid=userfield.userid AND $condition AND adminemail=1");
Also replace this:
$users=$DB_site->query("SELECT userid,usergroupid,username,email,joindate FROM user WHERE $condition AND adminemail=1 ORDER BY userid DESC LIMIT $startat,$perpage");
with this:
$users=$DB_site->query("SELECT userid,usergroupid,username,email,joindate FROM user,userfield WHERE user.userid=userfield.userid AND $condition AND adminemail=1 ORDER BY userid DESC LIMIT $startat,$perpage");
Now, add this:
makehiddencode("homepage",$homepage);
after this:
makehiddencode("location",$location);
Also add this:
makeinputcode("and location contains","location");
after this:
makeinputcode("and homepage contains","homepage");
(Note: this appears *twice*)
And lastly replace this:
[code] $users=$DB_site->query("SELECT email FROM user WHERE $condition AND adminemail=1");
with this:
$users=$DB_site->query("SELECT email FROM user,userfield WHERE user.userid=userfield.userid AND $condition AND adminemail=1");
That's it I think.
mvigod
12-25-2001, 05:43 AM
Want to add a small twist to the above if you can. I want to search by location but just as part of the standard search query.
If someone enters "black hat texas" in the search query it will look for all posts that have "black hat texas" in them or all of the 3 terms either in the post or location field. So if I wanted to find all the black hats in texas I could just type that in and even if the text "black hat" appeared in the post and texas only appeared in the location field it would still show up.
Alternatively if easier add a second AND search box next to the standard query box on the regular main search page to put a location in if required. So "black hat" would go in the search box and "texas" would go into the box adjacent to it.
Search for ___________ in this location ______________
If you know how to do this could you PLEASE post it here. I did the hack on the memberlist search but really need it on the main search to be truly useful to our board and I know lots of people need this search hack too.
Thanks so much for any help you can provide!
mvigod
01-22-2002, 10:49 PM
Still working on this one...can one of you experts maybe point me in the right direction? I'm thinking you add another input field next to the search box such as "location" and then is it just a matter of extending the mySQL query along with some joins to match the results of the search to the users who made the posts that have the specific location in their custom user field?
Is it more involved than this or I am headed down the good path here?
Thanks.
scrapster
01-18-2008, 07:27 PM
this is an old thread, has this template changed? cause i can't find it but would love this feature. help??
memberlistsearch template
--------------- Added 1200697168 at 1200697168 ---------------
btw, i'm in version 3.6.3 and would love to add this!
scrapster
01-24-2008, 04:05 PM
pretty please??
Marco van Herwaarden
01-25-2008, 06:28 AM
This thread is most likely about vBulletin 2.x, instructions given here will not work on a later version.
I suggest you start a new thread with your question.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.