Viewing 8 replies - 1 through 8 (of 8 total)
  • Can you give me an exact example of what you need? Thanks.

    Thread Starter antwoorden

    (@antwoorden)

    Well, the location dropdown menu (in the Add event form) lists every location by name only. But I want it to list every location by name AND town.

    Example: location A is called ‘Market’ and is in ‘New York’. Location B is called ‘Market’ as well, but is in ‘Washington DC’. When a user adds an event, he gets to choose the location through the dropdown menu, which lists ‘Market’ twice. I want it to list ‘New York – Market’ and ‘Washington DC – Market’.

    Which parts of the location are “Market”? I’m assuming the city is the City part.

    Is this for user-submitted events?

    Thread Starter antwoorden

    (@antwoorden)

    Let me try to put it more clear:

    I enabled ‘Use dropdown for locations?’ in Events > Settings > General Options.

    Now, whenever a user submits an event, he gets to choose the location from a dropdown menu. That’s good, but I want the dropdown items not only to be named after their location name (as it’s now), but after the town of that location as well.

    So the locations in the dropdown should be listed as
    LOCATION_TOWN – LOCATION_NAME
    instead of just
    LOCATION_NAME

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can do that by modifying template file at events-manager/templates/forms/event/location.php

    to use template: http://wp-events-plugin.com/documentation/using-template-files/

    Thread Starter antwoorden

    (@antwoorden)

    Brilliant! That works. But the items are still sorted alphabetically by location_name, where I want to have it sorted alphabetically by location_town. How to do this?

    My code:

    <select name="location_id" id='location-select-id' size="1">
    					<?php if(!get_option('dbem_require_location',true)): ?><option value="0"><?php _e('No Location','dbem'); ?></option><?php endif; ?>
    					<?php
    					$ddm_args = array('blog'=>false, 'private'=>$EM_Event->can_manage('read_private_locations'));
    					$ddm_args['owner'] = (is_user_logged_in() && !current_user_can('read_others_locations')) ? get_current_user_id() : false;
    					$locations = EM_Locations::get($ddm_args);
    					$selected_location = !empty($EM_Event->location_id) ? $EM_Event->location_id:get_option('dbem_default_location');
    					foreach($locations as $EM_Location) {
    						$selected = ($selected_location == $EM_Location->location_id) ? "selected='selected' " : '';
    				   		?>
    				    	<option value="<?php echo $EM_Location->location_id ?>" title="<?php echo "{$EM_Location->location_latitude},{$EM_Location->location_longitude}" ?>" <?php echo $selected ?>><?php echo $EM_Location->location_town; ?> - <?php echo $EM_Location->location_name; ?></option>
    				    	<?php
    					}
    					?>
    				</select>

    Try changing the line that says

    $ddm_args = array('blog'=>false, 'private'=>$EM_Event->can_manage('read_private_locations'));

    to

    $ddm_args = array('blog'=>false, 'order'=>'ASC',  'orderby'=>'location_town','private'=>$EM_Event->can_manage('read_private_locations'));

    Thread Starter antwoorden

    (@antwoorden)

    Awesome! That works great 🙂
    Thanks caimin_nwl, great support!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Location dropdown: show town?’ is closed to new replies.