Results 1 to 10 of 259

Threaded View

  1. #11
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    984
    Plugin Contributions
    6

    Default How to add country dropdown that returns the country name

    Quote Originally Posted by dw08gm View Post
    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.
    Last edited by dw08gm; 10 Nov 2009 at 02:55 PM.

 

 

Similar Threads

  1. custom survey forms
    By cpk in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 2 May 2011, 05:07 PM
  2. Custom Forms
    By wwiii in forum General Questions
    Replies: 3
    Last Post: 11 May 2009, 05:51 PM
  3. Customer's seeing other users' data in forms
    By erikcw in forum General Questions
    Replies: 5
    Last Post: 30 Jan 2008, 11:30 PM
  4. Custom Collection of Attribute Data
    By Fastcar in forum General Questions
    Replies: 0
    Last Post: 15 Jan 2008, 01:01 PM
  5. Custom Forms - Help?
    By TurtleDove in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 9 Jun 2006, 02:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg