Home › Forums › Calendar Products › Events Calendar PRO › Location part of Tribe Events Bar
- This topic has 13 replies, 4 voices, and was last updated 5 years, 10 months ago by Victor.
-
AuthorPosts
-
November 28, 2016 at 6:37 am #1198237Sally NewcombParticipant
Using answers in other threads, I’ve nearly got this sorted, but can’t quite get it.
I’m trying to do 2 things:
1. Change the place holder text below the label near to: Enter Your Postcode (because this is a UK based website)
2. Add the word ‘miles’ after the number of miles returned by the location search.Regards 1. – I have manage to change the label, but it then prevents ‘search by location’ from working??
I’ve added the following to my functions file but changing the placeholder text to ‘Enter your Postcode’ for some reason stops the location search from working (when I removed the code from the functions.php it worked fine except the word miles still didn’t appear. What ever I put in the search box at the moment returns all events.
/*
* Change labels in Tribe events bar filter
*/add_filter( ‘tribe-events-bar-filters’, ‘tribe_support_1043886’ );
function tribe_support_1043886( $filters ) {
$value = ”;
if ( ! empty( $_REQUEST[‘tribe-bar-search’] ) ) {
$value = esc_attr( $_REQUEST[‘tribe-bar-search’] );
}$html = sprintf(
‘<input type=”text” name=”tribe-bar-geoloc” id=”tribe-bar-geoloc” value=”%s” placeholder=”%s”>’,
esc_attr( $value ),
‘Enter Your Postcode’
);$filters[‘tribe-bar-geoloc’][‘caption’] = ‘Near’;
$filters[‘tribe-bar-geoloc’][‘html’] = $html;return $filters;
}/*
* Change default distance label in Map View
*/
add_filter( ‘tribe_get_distance_with_unit’, ‘tribe_custom_distance_label’, 10, 3 );function tribe_custom_distance_label ( $distance, $distance_in_kms, $unit ) {
return ‘Distance From Location: ‘ . $distance . ‘ ‘ . $unit;
}November 28, 2016 at 1:49 pm #1198700CliffMemberHi Sally.
1)
The “Near” text is from Line 263 of /wp-content/plugins/events-calendar-pro/src/Tribe/Geo_Loc.php and can be changed via the code snippet at the bottom of https://theeventscalendar.com/knowledgebase/change-the-wording-of-any-bit-of-text-or-string/
2)
Go to wp-admin > Events > Settings > General tab > Map Settings section and change “Distance unit” from Miles to Kilometers
November 28, 2016 at 2:19 pm #1198716Sally NewcombParticipantGo to wp-admin > Events > Settings > General tab > Map Settings section and change “Distance unit” from Miles to Kilometers
I had already done that and it was already set to kilometres but still doesn’t work. In fact, I want it set to miles, not kilometres….. Should this work?:
/*
* Change default distance label in Map View
*/
add_filter( ‘tribe_get_distance_with_unit’, ‘tribe_custom_distance_label’, 10, 3 );function tribe_custom_distance_label ( $distance, $distance_in_miles, $unit ) {
return ‘Distance From Location: ‘ . $distance . ‘ ‘ . $unit;
}If I add this to my functions.php, I just get a white screen:
$custom_text = array(
‘Venue’ => ‘Location’,
‘Related %s’ => ‘Similar %s’,
);November 28, 2016 at 3:07 pm #1198763CliffMemberI see from your System Information (that you provided on-demand access to), that geoloc_default_unit = miles, so, yes, you do have that setting to “Miles” instead of “Kilometers”.
Could you please provide an annotated screenshot demonstrating the issue, along with a link to view an example event this is happening at?
Additionally, your code snippet looks incomplete. Please make sure you’re using the code snippet at the very bottom of that KB article.
Thank you.
December 13, 2016 at 4:15 am #1205120Sally NewcombParticipantThis reply is private.
December 13, 2016 at 8:26 am #1205244CliffMemberThis reply is private.
December 13, 2016 at 8:28 am #1205253Sally NewcombParticipantThis reply is private.
December 13, 2016 at 6:58 pm #1205660CliffMemberGot it. Thanks.
That is coming from tribe_event_distance(), which is used in /wp-content/plugins/events-calendar-pro/src/views/pro/map/single-event.php
You can use the Themer’s Guide to override that file to insert ” miles” or whatever you choose.
Please let me know if this answers your question.
December 15, 2016 at 2:29 am #1206321Sally NewcombParticipantI’ve followed the steps in the Themer’s Guide which results in this path: /devdocs/wp-content/themes/dynamik-gen/tribe-events/pro/map/single-event.php
I hoped it would be as simple as adding Miles like below, but although the word Miles appears, it isn’t displayed in the same class and it shows even when user hasn’t searched for distance from location.
<!– Event Distance –>
<?php echo tribe_event_distance(); ?>
<span class=“tribe-events-distance”>Miles</span>What have I left out? Reading this thread, it looks like there’s more to do than just adding a word? https://theeventscalendar.com/support/forums/topic/describe-miles-after-search-result/
December 15, 2016 at 9:06 am #1206522CliffMembertribe_event_distance() uses tribe_get_distance_with_unit(), which is able to be filtered with tribe_get_distance_with_unit
So you could accomplish what you want 1 of 2 ways:
1)
Use the tribe_get_distance_with_unit filter, which may affect output elsewhere on your site.
https://theeventscalendar.com/tips-working-wordpress-actions-filters/ is a helpful reference.
2)
Do a template override to replace this:
<?php echo tribe_event_distance(); ?>
with this:
<?php $distance = tribe_event_distance(); if ( ! empty ( $distance ) ) { echo str_replace( '</span>', ' Miles</span>', $distance ); } ?>
I hope this helps.
December 16, 2016 at 12:26 am #1206944Sally NewcombParticipantThe template override worked perfectly, thank you so much!
December 16, 2016 at 9:52 am #1207139CliffMemberYou bet! 🙂
June 21, 2018 at 7:07 am #1558251VictorKeymasterHi There!
Just wanted to share with you that a new release of our plugins is out, including a fix for this issue 🙂
Find out more about this release → https://theeventscalendar.com/maintenance-release-week-17-june-2018/
We apologize for the delay and appreciate your patience while we worked on this.
Please update the plugins and see if the fix works for your site. Don’t hesitate to open a new topic if anything comes up.
Best,
Victor -
AuthorPosts
- The topic ‘Location part of Tribe Events Bar’ is closed to new replies.