Hallo! 1. I find common.inc.php to be very long! I just wondered that it could be possible to divide this file into smaller parts like mail.common.inc.php, smarty.common.inc.php, etc. Then it would become easier to work with it i.e. for all including the developers and updating would be also easier. 2. I am working with the following function: function load_countries_config () { This function loads the country list from a binary field which is loading a delimiter | under the ID | Name system of countries. 3. I am trying to change the behaviour of those area of the functions. Having 5.000 names out there is more than silly and shocking. Hence I need to do it. Currently, the aMember fields does not show any sensitivity towards choice of countries and loading states based on the choice. This could be achieved IF and only IF the field "countries" is not used and anathor table is used. So I create a table name aMember_countries and have ID Name FatherID 210 United states 0 (for e.g.) 1234 California 210 4. I have developed an independant script which would load countries and based on choice, it will load the states. Based on states it will load cities and drill down upto the end of the system until the last category is available. My problem: A. I need to connect to the table of aMember_countries B. How do I integrate with profile.html?
A. I recommend to keep country referenced by short name (US, not 210). and not by number. The same for states. B. Sorry, I don't understand question.
Hallo Alex! Well, you have designed a quick solution for the countries and states. This works however, you may realise that this would be a very difficult situation for many and would cause terrible restrictions. This is only because all the data is stored into ONE AND ONLY ONE field, i.e. countries for countries. I suggested to have a complete new table for countries baased on a hierarchial system where there are IDs and FatherIDs to be named as aMember_countries. Above, I was not very clear enough. However, I have completely redesigned your approach and have made it work with a REAL MYSQL solution of a new table aMember_countries RATHER THAN a ONE field solution. This works really wonderful and also the tax areas uses the same functions. The suggestion of using alphabet codes could be also trouble as they do not result into any level of mathametical equations in php or mysql. Hence working with a hierarchial solution you could equate as to country_id greater than 100 and less than 120 ... Further, the country_ids could be made such that they would allow a system of inserting more ids without breaking the hierarchy! This system I find it more useful and intellegent.
I agree with you it will be done, but in new aMember version with new architecture. Current version depends on this design a lot, it cannot be changed just in one place.
Hallo Alex! Well, I am surprised with your answer! By changing just in one place, it has been working everywhere, for instance in the User Registrations, Modifications, and Taxes. There are some other areas that requires small work. However, the ammount of time that can go in doing this is for a Programier like you really not much of work. I have a solution for myself and it works neately, ofcourse very specific to my demands. However I see the advantage for others that could definitely benifit from it.
Hallo Alex! I have done the following. It is quite self explainatory actually. It works with the profile.php and OnChange EventHandler where the redirection is NOT to member.php but remains within the profile.php. Respective modifications are also done in the templates like config_options, html, etc. Now if there is an ID, then it does not activate an Event in the admin, even if I have the necessary variables in the <form>, <input> and <submit> out there. It changes the state based on chosen countries based on selected country and the same for cities. This will also work for taxes. However it does not work in the signup where there is smarty appearing. Can you help me to get it going? Thanks in advance. If other users wanna use it, I could explain a bit more, provided if it works in the signup. common.inc.php Code: [B]function load_countries_config[/B] () { global $t, $vars, $db, $config, $member_id; $config['country_options'] = array (); $config['country_options']["199"] = _TPL_COMMON_SELECT_COUNTRY; $config['state_options'] = array (); $config['state_options']["0"] = _TPL_COMMON_SELECT_STATE; $config['city_options'] = array (); $config['city_options']["0"] = _TPL_COMMON_SELECT_CITY; if (strlen($_SESSION['_amember_user']['login'])){ // found user session $member_id = intval($_SESSION['_amember_user']['member_id']); } else { if (!strlen($login)) $login = $_SERVER['PHP_AUTH_USER']; if (!strlen($login)) $login = $_SERVER['REMOTE_USER']; $ul = $db->users_find_by_string($login, 'login', 1); $member_id = $ul[0]['member_id']; } $member_data=$db->query("SELECT city, state, country FROM {$db->config[prefix]}members WHERE member_id = '$member_id'"); $row_member_data = mysql_fetch_assoc($member_data); $member_country = $row_member_data['country']; $member_state = $row_member_data['state']; $member_city = $row_member_data['city']; $query_countries_FatherID=$db->query("SELECT ID, Name, FatherID FROM amember_regions WHERE FatherID > 100 AND FatherID < 199 ORDER BY Name"); while ($row_countries_FatherID = mysql_fetch_assoc($query_countries_FatherID)){ $config['country_options'][$row_countries_FatherID['ID']]=$row_countries_FatherID['Name']; } $countries_ID = $config['country_options'][$row_countries_FatherID['ID']]; $countries_Name = $row_countries_FatherID['Name']; $config['country_options'][$countries_ID] = $countries_Name; $query_member_state_FatherID=$db->query("SELECT ID, Name, FatherID FROM amember_regions WHERE FatherID = '$member_country'"); while ($row_member_state_FatherID = mysql_fetch_assoc($query_member_state_FatherID)){ $config['state_options'][$row_member_state_FatherID['ID']]=$row_member_state_FatherID['Name']; } $member_state_ID = $config['state_options'][$row_member_state_FatherID['ID']]; $member_state_Name = $row_member_state_FatherID['Name']; $config['state_options'][$member_state_ID] = $member_state_Name; $query_member_city_FatherID=$db->query("SELECT ID, Name, FatherID FROM amember_regions WHERE FatherID = '$member_state' ORDER BY Name"); if ($member_state > 199) { while ($row_member_city_FatherID = mysql_fetch_assoc($query_member_city_FatherID)){ $config['city_options'][$row_member_city_FatherID['ID']]=$row_member_city_FatherID['Name']; } if ( !empty($member_city) ) { $member_city_ID = $config['city_options'][$row_member_city_FatherID['ID']]; $member_city_Name = $row_member_city_FatherID['Name']; $config['city_options'][$member_city_ID] = $member_city_Name; } }
Hi Draj, Did you ever get this counties|states script working. If you did can you provide some insight as to how. Best regards Dereck