Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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
    Mike

    #1220648

    Hey Michael,

    Where, on which lines are you adding the code?

    Best regards,
    Victoria

    #1220744

    Hey 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 = "&nbsp;";
    					}
    					/* 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
    Mike

    #1221358

    Hi 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,
    Victoria

    #1221559

    Hi 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
    Mike

    #1221776

    Hi 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,
    Victoria

    #1221862

    Hi 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
    Mike

    #1222263

    Hi Mike,

    Thanks for the update. I’ll go ahead and close this thread for now then, please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Using filter instead of file copy’ is closed to new replies.