
Originally Posted by
dw08gm
I have created a supplier registration form based on this mod, where the only remaining problem is getting the Country to display as its Name rather than its Number (eg "Australia" rather than "13") after selection from the Country dropdown menu.
Rather than post the entire files, references to Country are as follows:
includes/modules/pages/supplier_registration/header_php.php
Line 33
$country = '';
After if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
Line 61
$country = zen_db_prepare_input($_POST['zone_country_id']);
After // BOF Error Messages
Line 111
if (!zen_not_null($country)) {
$error = true;
$messageStack->add('supplier_registration', 'Please select your country');
}
After //assemble the email contents:
Line 203
'country:' . "\t" . $country . "\n" .
includes/templates/your_template/tpl_supplier_registration_default.php
After <fieldset>
Line 76
<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>
<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" ') . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>
What have I done wrong?
TIA
How to add country dropdown that returns the country name, rather than country_id number, in email forms (eg band_signup).
Further to my posts above, I think I have a solution. Although not thoroughly tested, eg text vs html emails, the country name now appears as such in Email Archive Manager. If anyone has a better solution, please post.)
A. In includes\functions\html_output.php, towards the end of the file and immediately before
Code:
/*
* Assesses suitability for additional parameters such as rel=nofollow etc
*/
add
Code:
/*
* Creates a pull-down list of countries names (and extract country name)
*/
function zen_get_country_listname($name, $selected = '', $parameters = '') {
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = zen_get_countries();
for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
$countries_array[] = array('id' => $countries[$i]['countries_name'], 'text' => $countries[$i]['countries_name']);
}
return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
}
Notes A:
1. This code is a copy of the preceeding function zen_get_country_list, except 'countries_id' is replaced by 'countries_name'.
2. There is no override for includes\functions\html_output.php, therefore upon upgrade, the new file may have to be edited accordingly.
3. Ideally this code would be placed in either includes\modules\pages\your_page\header_php.php or includes\templates\your_template\templates\tpl_your_page_default.php, but I am unsure about the placement. Anyone?
B. In includes\modules\pages\your_page\header_php.php, after
Code:
if (isset($_GET['action']) && ($_GET['action'] == 'send')) {
add (or change to)
Code:
$country = zen_db_prepare_input($_POST['countries_name']);
C. In includes\templates\your_template\templates\tpl_your_page_default.php, amongst the list of <labels>
add (or change to)
Code:
<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>
<?php echo zen_get_country_listname('countries_name', $selected_country, 'id="country"') . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
Notes B and C:
1. If adding (rather than replacing) the code from steps B and C, you will need to add the other bits of code as per the above quoted post.
Bookmarks