-
AuthorPosts
-
June 8, 2020 at 3:49 pm #1220505
Hi
We show additional infos at the upcoming events (plugin The Evens Calendar) on a website.
For that, we copied the file events_upcoming.php and edited it like this:$additional_fields = tribe_get_custom_fields(); if ($additional_fields['Infos']) { $infos = $additional_fields['Infos']; } else { $infos = " "; }
And later:
if ($infos) $event .= "<span class='av-upcoming-event-infos'><strong>{$infos}</strong></span>";
Is it also possible to add this infos not with a copied events_upcoming.php file? For example using the filter avf_upcoming_event_extra_data?
If yes, how we can do that?
Thanks very much.
Best regards
MikeJune 8, 2020 at 9:11 pm #1220648Hey Michael,
Where, on which lines are you adding the code?
Best regards,
VictoriaJune 9, 2020 at 8:11 am #1220744Hey Victoria
We add this code in the function shortcode_handler, line 276. Here the whole foreach in there:foreach( $entries as $index => $entry ) { $class = 'av-upcoming-event-entry'; $image = get_the_post_thumbnail( $entry->ID, 'square', array( 'class' => 'av-upcoming-event-image' ) ); $class .= ! empty( $image ) ? ' av-upcoming-event-with-image' : ' av-upcoming-event-without-image'; $title = get_the_title( $entry->ID ); $link = get_permalink( $entry->ID ); $post->ID = $entry->ID; //temp set of the post id so that tribe fetches the correct price symbol $price = tribe_get_cost( $entry->ID, true ); $venue = tribe_get_venue( $entry->ID ); /* ADDED FOR INFOS - START */ $additional_fields = tribe_get_custom_fields(); if ($additional_fields['Infos']) { $infos = $additional_fields['Infos']; } else { $infos = " "; } /* ADDED FOR INFOS - END */ $post->ID = $default_id; $event = ''; $event .= "<a href='{$link}' class='{$class}'>"; if( $image ) { $event .= $image; } $event .= "<span class='av-upcoming-event-data'>"; $event .= "<h4 class='av-upcoming-event-title'>{$title}</h4>"; $event .= "<span class='av-upcoming-event-meta'>"; /* ADDED FOR INFOS - START */ if ($infos) $event .= "<span class='av-upcoming-event-infos'><strong>{$infos}</strong></span>"; /* ADDE FOR INFOS - END */ $event .= "<span class='av-upcoming-event-schedule'>" . tribe_events_event_schedule_details($entry) . "</span>"; if( $price ) { $event .= "<span class='av-upcoming-event-cost'>{$price}</span>"; } if( $price && $venue ) { $event .= ' - '; } if( $venue ) { $event .= "<span class='av-upcoming-event-venue'>{$venue}</span>"; } $event .= apply_filters( 'avf_upcoming_event_extra_data', '', $entry ); $event .= '</span>'; $event .= '</span>'; $event .= '</a>'; /** * Allows to change the output * * @since 4.5.6.1 * @param string $event * @param array $entries WP_Post * @param int $index * @return string */ $output .= apply_filters( 'avf_single_event_upcoming_html', $event, $entries, $index ); }
The added code is between the two “ADDED FOR INFOS – START” and “ADDED FOR INFOS – END”
Best regards
MikeJune 10, 2020 at 7:46 pm #1221358Hi Mike,
Thank you.
Well, it’s in the event rendering logic and there are no filters around, so the way you did it is the way to go.
If you need further assistance please let us know.
Best regards,
VictoriaJune 11, 2020 at 8:04 am #1221559Hi Victoria
Okey.
So, it would be nice, if Enfold could implement the possibility to show the additional info (is an extensions of The Events Calendar PRO) there ;-)
Until then we would do it like this ;-)
Best regards
MikeJune 11, 2020 at 4:41 pm #1221776Hi Mike,
Customizing other plugins templates is not really the theme function. It is the custom functionality that is to be built by other devs.
If you need further assistance please let us know.
Best regards,
VictoriaJune 11, 2020 at 6:34 pm #1221862Hi Victoria
Ah ok. I thought, this was an Enfold file (events_upcoming.php), that’s why I thought, you could enhance it in a later release ;-)
But it’s no problem. It works with this modification, so we are still happy ;-)
You can close this issue.
Best regards
MikeJune 13, 2020 at 5:42 am #1222263 -
AuthorPosts
- The topic ‘Using filter instead of file copy’ is closed to new replies.