Would anyone know if there is any way I can add Canadian Provinces and US States in the Admin Edit States menu without them all mixing up alphabetically? See attached screen cap, the US and Provinces are all mixed up. I simply want to show both US and Canadian in order by country. Like this: http://www.thefixor.com/help/StateProv.html Any help would be much appreciated!
Hmm, interesting question. They are words and sorted alphabetically so without adding a bunch of code to allow them to be manually given a weight via an additional field to alter their order the only thing I can think of off the top of my head would be to prepend the state and/or province with a country abbreviation.
I tried adding USA or CAN and it didn't work, they are sorted alphabetically every-time when I try to add states to the menu. You have a point weight would be a good solution but unfortunately it does not exist in the admin section. Thank you.
did you add USA and CAN to the abbreviation field or full name field? Off the top of my head I dont know which is uses to sort the output, but if you only tried adding it to one (ie abbreviation) then try adding USA and/or CAN to the full name and see if that alters the output.
Perhaps I'm either misunderstanding you or you're misunderstanding Larry's suggestion. So did you add USA-Alabama, USA-Arkansas... CAN-Quebec... or did you just add two new entries, CAN & USA? -- Added edit -- It's sorted by the name -Mike
I simply did this for USA states: Edit States ------------- State > [Alabama] State Abbreviation [USA] And this for Provinces: State > [Alberta] State Abbreviation [CAN] If I add USA or CAN in front of the state it will look silly. See attachment. Any other options?
Since you have the developer version, you could actually modify the sort in the getStates function in the Users.php file. add the abbrev ASC before the existing name ASC. -Mike
Im sorry where is this file located? I did a search and my PC found multiple files of that name. Also what line would this be found under and how would I modify?
I guess actually the proper syntax would be "ORDER BY abbrev, name ASC" I think that should do it. -Mike
Here is what I found: function getStates() { global $db; $sSQL="SELECT name FROM ".PREFIX."states ORDER BY name ASC"; $result=$db->query($sSQL); while($rs=$result->fetch()){ $states[]=$rs; } $result->freeResult(); return $states; } Modified: $sSQL="SELECT name FROM ".PREFIX."ORDER BY abbrev, name ASC"; Is this correct? Thanks!
That's exactly what you're looking for. Just add the abbrev to the ORDER by like this: $sSQL="SELECT name FROM ".PREFIX."states ORDER BY abbrev, name ASC"; Always keep a back up! Always comment your modifications, so you know what you did later on! -Mike
I just added Hawaii and it came up 3rd on the list. The code did not change anything. Am I doing something wrong?
The suggested modification was based on the assumption of what you stated earlier in that you entered "CAN" and "USA" in the abbrev fields for the states. It should work as it is sorting by the abbreviation first then by the name. -Mike
I added the states abbrev USA and CAN but I does not seem to work. It still picks up the state name before the abbreviation.
Hmmm, the only thing I can think is that you may need to also select the abbrev in order to ORDER BY it. Try this: $sSQL="SELECT name, abbrev FROM ".PREFIX."states ORDER BY abbrev, name ASC"; -Mike
I tried that now, but no luck. Same thing. Should this reflect in my "/administration/settingsstates.php" admin view?