PDA

View Full Version : Sort Members By State!


ranger2kxlt
06-07-2003, 10:00 PM
Well since no one offered to make it for me, I have made it myself. I now have the full working version of the sort by state hack.

This is a rather large hack, although easy.
Install Time: 15 mins

Alright basically, I took out the default Location field in the vbulletin registration process and hardcoded a new one in. This does require you to lose data regarding you members locations. Simply PM all of them and ask them to update their profiles afterwards making the change.

Anyways. When you do sort by state, I took into account that some people will not return to your site and/or will not edit their profile, and therefor when you do sort by state, anyone with an invalid or blank state field will not be displayed. On my site this is a required field and it is set up that way in this hack.

You can see a live sample of this hack at my site,
http://www.thunderbirdnest.com/vb/memberlist.php?s=&what=state

Alright... one more thing before we get to the file.

There is more to come in the future.
1) Admin Functions - I would like to add the ability for admins to edit the location of members after this hack. They can still do if via the database.
2) State by State Sorting - View members from a single state of your choosing instead of all states.

THIS HACK IS ONLY SET UP TO SUPPORT THE UNITED STATES AND CANADA! BUT IT CAN BE EASILY MODIFIED FOR THOSE THAT NEED IT BY COUNTRY!

Please read through the hack slowly and carefully and as normal back up your files before you edit them.


One final note I promise. Thanks to hellsatan for his assistance on a few sections of this hack. I greatly appreciated his assistance.

DOWNLOAD ATTACHMENT HERE! (https://vborg.vbsupport.ru/attachment.php?s=&postid=406142)

ranger2kxlt
06-08-2003, 06:54 AM
Screenshots time!

This is the memberlist

ranger2kxlt
06-08-2003, 06:55 AM
User CP - Edit Profile

ranger2kxlt
06-08-2003, 06:55 AM
Register

ranger2kxlt
06-08-2003, 06:55 AM
Profile

ranger2kxlt
06-08-2003, 06:58 AM
Postbit

Vile
06-08-2003, 06:59 AM
Neat idea :)

I'll probably test this out.

Thanks for sharing :)

ranger2kxlt
06-08-2003, 07:05 AM
Thank you, please let me know if you like :)

Dean C
06-08-2003, 09:03 AM
Might want to change any instances of yellow in the post to use the [high] vbcode :)

Also in your sig ;) Then it shows up as red on this style, yelloe on the blue style and something else on the purple style :p

- miSt

ranger2kxlt
06-08-2003, 02:52 PM
Please click install if you try this hack! I would greatly appreciate seeing how many people install it!

Xelation
06-08-2003, 03:28 PM
just installed it with a few modifications such as full names for the states and I added provinces.... I was wondering though, when someone modifies their profile and say they pick newyorkstate.... when they click modify at the bottom everything is changed correctly but when they go to modify it again its back at alabama and I was wondering, what would I need to do to keep it at the state they picked.. get what I mean?

ranger2kxlt
06-08-2003, 03:40 PM
Yes...

When you made this modification, you would have needed to edit 3 different places!

First is registeradult template... add your provinces etc.
<td bgcolor="{secondaltcolor}"><normalfont><b>Location (City, State):</b></normalfont><br>
<smallfont>Your Location</smallfont></td>
<td bgcolor="{secondaltcolor}"><normalfont><input type="text" class="bginput" name="city" size="25" maxlength="50">,&nbsp;<select name="state" size="1">
<OPTION>AL</OPTION>
<OPTION>AK</OPTION>
<OPTION>AZ</OPTION>
<OPTION>AR</OPTION>
<OPTION>CA</OPTION>
<OPTION>CAN</OPTION>
<OPTION>CO</OPTION>
<OPTION>CT</OPTION>
<OPTION>DE</OPTION>
<OPTION>FL</OPTION>
<OPTION>GA</OPTION>
<OPTION>HI</OPTION>
<OPTION>ID</OPTION>
<OPTION>IL</OPTION>
<OPTION>IN</OPTION>
<OPTION>IA</OPTION>
<OPTION>KS</OPTION>
<OPTION>KY</OPTION>
<OPTION>LA</OPTION>
<OPTION>ME</OPTION>
<OPTION>MD</OPTION>
<OPTION>MA</OPTION>
<OPTION>MI</OPTION>
<OPTION>MN</OPTION>
<OPTION>MS</OPTION>
<OPTION>MO</OPTION>
<OPTION>MT</OPTION>
<OPTION>NE</OPTION>
<OPTION>NV</OPTION>
<OPTION>NH</OPTION>
<OPTION>NJ</OPTION>
<OPTION>NM</OPTION>
<OPTION>NY</OPTION>
<OPTION>NC</OPTION>
<OPTION>ND</OPTION>
<OPTION>OH</OPTION>
<OPTION>OK</OPTION>
<OPTION>OR</OPTION>
<OPTION>PA</OPTION>
<OPTION>RI</OPTION>
<OPTION>SC</OPTION>
<OPTION>SD</OPTION>
<OPTION>TN</OPTION>
<OPTION>TX</OPTION>
<OPTION>UT</OPTION>
<OPTION>VT</OPTION>
<OPTION>VA</OPTION>
<OPTION>WA</OPTION>
<OPTION>WV</OPTION>
<OPTION>WI</OPTION>
<OPTION>WY</OPTION>
</select></normalfont></td>
</tr>

Next would be modifyprofile: Make sure the $location increments with each additional state/province you add.
<tr>
<td bgcolor="{secondaltcolor}"><normalfont><b>Location (City, State):</b></normalfont><br>
<smallfont>Your Location</smallfont></td>
<td bgcolor="{secondaltcolor}"><normalfont><input type="text" class="bginput" name="city" value="$bbuserinfo[city]" size="25" maxlength="50">,&nbsp;<select name="state" value="$bbuserinfo[state]" size="1">
<OPTION $location2>AL</OPTION>
<OPTION $location3>AK</OPTION>
<OPTION $location4>AZ</OPTION>
<OPTION $location5>AR</OPTION>
<OPTION $location6>CA</OPTION>
<OPTION $location1>CAN</OPTION>
<OPTION $location7>CO</OPTION>
<OPTION $location8>CT</OPTION>
<OPTION $location9>DE</OPTION>
<OPTION $location10>FL</OPTION>
<OPTION $location11>GA</OPTION>
<OPTION $location12>HI</OPTION>
<OPTION $location13>ID</OPTION>
<OPTION $location14>IL</OPTION>
<OPTION $location15>IN</OPTION>
<OPTION $location16>IA</OPTION>
<OPTION $location17>KS</OPTION>
<OPTION $location18>KY</OPTION>
<OPTION $location19>LA</OPTION>
<OPTION $location20>ME</OPTION>
<OPTION $location21>MD</OPTION>
<OPTION $location22>MA</OPTION>
<OPTION $location23>MI</OPTION>
<OPTION $location24>MN</OPTION>
<OPTION $location25>MS</OPTION>
<OPTION $location26>MO</OPTION>
<OPTION $location27>MT</OPTION>
<OPTION $location28>NE</OPTION>
<OPTION $location29>NV</OPTION>
<OPTION $location30>NH</OPTION>
<OPTION $location31>NJ</OPTION>
<OPTION $location32>NM</OPTION>
<OPTION $location33>NY</OPTION>
<OPTION $location34>NC</OPTION>
<OPTION $location35>ND</OPTION>
<OPTION $location36>OH</OPTION>
<OPTION $location37>OK</OPTION>
<OPTION $location38>OR</OPTION>
<OPTION $location39>PA</OPTION>
<OPTION $location40>RI</OPTION>
<OPTION $location41>SC</OPTION>
<OPTION $location42>SD</OPTION>
<OPTION $location43>TN</OPTION>
<OPTION $location44>TX</OPTION>
<OPTION $location45>UT</OPTION>
<OPTION $location46>VT</OPTION>
<OPTION $location47>VA</OPTION>
<OPTION $location48>WA</OPTION>
<OPTION $location49>WV</OPTION>
<OPTION $location50>WI</OPTION>
<OPTION $location51>WY</OPTION>
</select></normalfont></td>
</tr>


Then and here is probably where you need it. Make sure the $locations match up with the modify profile template.
Member.php
if ($bbuserinfo[state] == 'CAN') {
$location1 = SELECTED;
} elseif ($bbuserinfo[state] == 'AL') {
$location2 = SELECTED;
} elseif ($bbuserinfo[state] == 'AK') {
$location3 = SELECTED;
} elseif ($bbuserinfo[state] == 'AZ') {
$location4 = SELECTED;
} elseif ($bbuserinfo[state] == 'AR') {
$location5 = SELECTED;
} elseif ($bbuserinfo[state] == 'CA') {
$location6 = SELECTED;
} elseif ($bbuserinfo[state] == 'CO') {
$location7 = SELECTED;
} elseif ($bbuserinfo[state] == 'CT') {
$location8 = SELECTED;
} elseif ($bbuserinfo[state] == 'DE') {
$location9 = SELECTED;
} elseif ($bbuserinfo[state] == 'FL') {
$location10 = SELECTED;
} elseif ($bbuserinfo[state] == 'GA') {
$location11 = SELECTED;
} elseif ($bbuserinfo[state] == 'HI') {
$location12 = SELECTED;
} elseif ($bbuserinfo[state] == 'ID') {
$location13 = SELECTED;
} elseif ($bbuserinfo[state] == 'IL') {
$location14 = SELECTED;
} elseif ($bbuserinfo[state] == 'IN') {
$location15 = SELECTED;
} elseif ($bbuserinfo[state] == 'IO') {
$location16 = SELECTED;
} elseif ($bbuserinfo[state] == 'KS') {
$location17 = SELECTED;
} elseif ($bbuserinfo[state] == 'KY') {
$location18 = SELECTED;
} elseif ($bbuserinfo[state] == 'LA') {
$location19 = SELECTED;
} elseif ($bbuserinfo[state] == 'ME') {
$location20 = SELECTED;
} elseif ($bbuserinfo[state] == 'MD') {
$location21 = SELECTED;
} elseif ($bbuserinfo[state] == 'MA') {
$location22 = SELECTED;
} elseif ($bbuserinfo[state] == 'MI') {
$location23 = SELECTED;
} elseif ($bbuserinfo[state] == 'MN') {
$location24 = SELECTED;
} elseif ($bbuserinfo[state] == 'MS') {
$location25 = SELECTED;
} elseif ($bbuserinfo[state] == 'MO') {
$location26 = SELECTED;
} elseif ($bbuserinfo[state] == 'MT') {
$location27 = SELECTED;
} elseif ($bbuserinfo[state] == 'NE') {
$location28 = SELECTED;
} elseif ($bbuserinfo[state] == 'NV') {
$location29 = SELECTED;
} elseif ($bbuserinfo[state] == 'NH') {
$location30 = SELECTED;
} elseif ($bbuserinfo[state] == 'NJ') {
$location31 = SELECTED;
} elseif ($bbuserinfo[state] == 'NM') {
$location32 = SELECTED;
} elseif ($bbuserinfo[state] == 'NY') {
$location33 = SELECTED;
} elseif ($bbuserinfo[state] == 'NC') {
$location34 = SELECTED;
} elseif ($bbuserinfo[state] == 'ND') {
$location35 = SELECTED;
} elseif ($bbuserinfo[state] == 'OH') {
$location36 = SELECTED;
} elseif ($bbuserinfo[state] == 'OK') {
$location37 = SELECTED;
} elseif ($bbuserinfo[state] == 'OR') {
$location38 = SELECTED;
} elseif ($bbuserinfo[state] == 'PA') {
$location39 = SELECTED;
} elseif ($bbuserinfo[state] == 'RI') {
$location40 = SELECTED;
} elseif ($bbuserinfo[state] == 'SC') {
$location41 = SELECTED;
} elseif ($bbuserinfo[state] == 'SD') {
$location42 = SELECTED;
} elseif ($bbuserinfo[state] == 'TN') {
$location43 = SELECTED;
} elseif ($bbuserinfo[state] == 'TX') {
$location44 = SELECTED;
} elseif ($bbuserinfo[state] == 'UT') {
$location45 = SELECTED;
} elseif ($bbuserinfo[state] == 'VT') {
$location46 = SELECTED;
} elseif ($bbuserinfo[state] == 'VA') {
$location47 = SELECTED;
} elseif ($bbuserinfo[state] == 'WA') {
$location48 = SELECTED;
} elseif ($bbuserinfo[state] == 'WV') {
$location49 = SELECTED;
} elseif ($bbuserinfo[state] == 'WI') {
$location50 = SELECTED;
} elseif ($bbuserinfo[state] == 'WY') {
$location51 = SELECTED;
}

ranger2kxlt
06-08-2003, 03:46 PM
Just a clarification note for the others that are looking to install this hack... It works fully on mine. When a user edits their profile it does show their previous location and state with no problems. :)

Xelation
06-08-2003, 03:48 PM
Ah, it works now.. I must of done something wrong.. great hack! :)

ranger2kxlt
06-08-2003, 03:53 PM
Found a VERY minor bug. I had originally set up the state row in the user table to only accept 2 characters because I was only planning to use states. Then after a member notified me that everytime they selected CAN (Canada) their profile would display CA (California). So I made the change.

For those of you that have already installed this, Run this query!
ALTER TABLE `user` CHANGE `state` `state` CHAR( 5 ) NOT NULL

Here is the new attachment!

ranger2kxlt
06-08-2003, 03:54 PM
Today at 11:48 AM Xelation said this in Post #14 (https://vborg.vbsupport.ru/showthread.php?postid=406139#post406139)
Ah, it works now.. I must of done something wrong.. great hack! :)

Thank you!

Chris M
06-08-2003, 07:50 PM
Very nice Justin:)

I will modify this hack to include English counties and test it out:)

Satan

ranger2kxlt
06-10-2003, 01:31 AM
bump

99SIVTEC
06-10-2003, 03:06 AM
Has anyone taken this a step further and made a US map that is clickable like the one over at http://dodgetalk.com/forums/memberstates.php?s=

ranger2kxlt
06-23-2003, 01:12 PM
I have not done so yet, but my plans are to do so in the future so states can be sorted seperatly instead of one large listing, kinda like the way the usernames can be sorted by letter in alphabetical order.

Importhookup
07-06-2003, 07:50 AM
Does this hack work for version 2.3.0?

ranger2kxlt
08-06-2003, 03:42 AM
It should yes. As for 3.0.0, i doubt it as i havent even looked at that new version yet.

ranger2kxlt
12-31-2003, 05:41 PM
bump

oldford
05-24-2004, 09:02 PM
Is this hack going to be updated for 3.0?

joeychgo
05-24-2004, 10:36 PM
I want to know as well..........

ranger2kxlt
05-27-2004, 06:08 AM
To sort by state in version 3.0.0 you dont need a hack. Just create a new profile field as a drop down box through the control panel and add all states and countries you wish you use. Then just link somewhere on your forums to the advanced search of the memberlist option. They can search the memberlist by certain profile fields, just enter the state your looking for and there you have it.

At least thats how i did it on my version of 3.0.0.

*Note that you must enable the Field Searchable on Members List? option in the profile field manager when creating the new field. Enjoy.

oldford
05-27-2004, 01:40 PM
Ahhh...hadn't even thought of that. I don't have my 3.x live yet, but I'll give it a shot. Thanks!