drop down for provinces in Add Events

Home Forums Calendar Products Community Events drop down for provinces in Add Events

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #267576
    Tran
    Participant

    I am trying to customize my venue.php and tribe-view-helpers-class.php files so that when users ‘add events’ they can select a country (2 options available canada and unites states), and depending on their choice a drop down will appear with states (which it already does), and if they choose canada, a drop down will appear with provinces.

    Ive added a loadProvinces() into tribe-view-helpers-class.php, that has all the canadian provinces in it. And Ive added to the venue.php

    <select class=”chosen” id=”StateProvinceSelect” name=”venue[Province]”>
    <option value=””><?php _e( ‘Select a Province’, ‘tribe-events-community’ ); ?></option>
    <?php foreach ( TribeEventsViewHelpers::loadProvinces() as $abbr => $fullname ) {
    echo ‘<option value=”‘ . esc_attr($abbr) .'” ‘;
    selected( $venue_province == $abbr );
    echo ‘>’. esc_html( $fullname ) .'</option>’. “\n”;
    } ?>
    </select>

    However, it only shows up when the United States are selected, and will not show up if you select Canada… where in this file, is the limiter that either hides or makes visible the united states dropdown menu, and how can I get my provinces to show up for Canada?

    #270034
    Barry
    Member

    Hi!

    Though we can’t offer too much assistance with customizations like this one I’d be happy to point you in the right direction if I can. Can you provide a little more context, though? Are you trying to achieve this in the (Community Events) submission form, or the admin environment generally, or both?

    Thanks!

    #335980
    Tran
    Participant

    The community events submission form,
    thanks

    #347821
    Barry
    Member

    OK, so the first thing here is to read up on the process of overriding templates – this and more is detailed in our Themer’s Guide and is well worth a read.

    From there you will probably want to setup a custom version of the community/modules/venue.php template (and this would live within your theme’s tribe-events directory). Find the following line of code:

    <input id="StateProvinceText" name="venue[Province]" type="text" name="" size="25" value="<?php echo ( isset( $venue_province ) && $venue_province != '' && $venue_province != -1 ) ? esc_attr($venue_province) : ''; ?>" />

    Replace it with something like this, adapting it to your specific use-case:

    <select id="StateProvinceText" name="venue[Province]">
    	<option value="rgn1"> Region one </option>
    	<option value="rgn2"> Region two </option>
    	<option value="rgn3"> Region three </option>
    </select>

    (Naturally you would need logic to pre-select whichever province might already have been selected.)

    I hope that gets you on track – and good luck 🙂

    #701627
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘drop down for provinces in Add Events’ is closed to new replies.