Forum Replies Created
-
AuthorPosts
-
David
ParticipantGreat thanks, that worked great. I’m using it as a “spare field”. My events never have a cost, so I’m using the currency field as an ordinal value cheat. I’ve adapted the list widget to display the featured image for any event and I use whether or not the currency symbol is a ‘X’ to determine whether clicking on the featured image in the widget should link to the Event details or directly to the Event website.
Code below if anyone is interested.
<?php /** * Events Pro List Widget Template * This is the template for the output of the events list widget. * All the items are turned on and off through the widget admin. * There is currently no default styling, which is highly needed. * * Override this template in your own theme by creating a file at [your-theme]/tribe-events/pro/widgets/list-widget.php * * When the template is loaded, the following vars are set: * * @var string $start * @var string $end * @var string $venue * @var string $address * @var string $city * @var string $state * @var string $province * @var string $zip * @var string $country * @var string $phone * @var string $cost * @var array $instance * * @package TribeEventsCalendarPro * */ if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } // Retrieves the posts used in the List Widget loop. $posts = tribe_get_list_widget_events(); // The URL for this widget's "View More" link. $link_to_all = tribe_events_get_list_widget_view_all_link( $instance ); // Check if any posts were found. if ( isset( $posts ) && $posts ) :?> <?php foreach ( $posts as $post ) : setup_postdata( $post ); do_action( 'tribe_events_widget_list_inside_before_loop' ); ?> <!-- Event --> <div class="<?php tribe_events_event_classes() ?>"> <?php $currency_symbol = tribe_get_event_meta( $postId, '_EventCurrencySymbol', true ); if ($currency_symbol == 'X') { // use the web site we've set as the event $website_url = tribe_get_event_website_url( $postId ); } else { // link to the event page $website_url = esc_url( tribe_get_event_link() ); }?> <?php if ( !empty( $website_url ) ) { echo '<a href="' . $website_url . '">'; }?> <div class="tribe_navigator_image"> <?php echo get_the_post_thumbnail( $post->ID, 'medium' );?> </div> <?php if ( !empty( $website_url ) AND $currency_symbol !='X') { echo '</a>'; }?> <?php tribe_get_template_part( 'pro/widgets/modules/single-event', null, $instance ) ?> <?php if ( !empty( $website_url ) AND $currency_symbol =='X') { echo '</a>'; }?> </div><!-- .hentry .vevent --> <?php do_action( 'tribe_events_widget_list_inside_after_loop' ) ?> <?php endforeach ?> <p class="tribe-events-widget-link"> <a href="<?php esc_attr_e( esc_url( $link_to_all ) ) ?>" rel="bookmark"> <?php esc_html_e( 'View More…', 'tribe-events-calendar-pro' ) ?> </a> </p> <?php // No Events were found. else: ?> <p><?php //printf( __( 'ORIGINAL There are not any upcoming %s at this time.', 'tribe-events-calendar' ), strtolower( tribe_get_event_label_plural() ) ); ?></p> <?php endif; // Cleanup. Do not remove this. wp_reset_postdata();David
ParticipantI’m guessing it must be something in the theme then that’s stopping it. Have over written the widget for the time being.
David
ParticipantWhere am I going wrong ?
I created the folder structure
/wp-content/themes/cake/tribe-events/pro/widgets/
and copied in to there the file list-widget.phpI then edited the appropriate line thus
<p><?php printf( __( ‘COPY There are not any upcoming %s at this time.’
(i.e I added the word COPY)
I also (as a later test) edited the original file
/wp-content/plugins/events-calendar-pro/src/views/pro/widgets/list-widget.phpchanging the line to
<p><?php printf( __( ‘ORIGINAL There are not any upcoming %s at this time.’
When I viewed the web page the ORIGINAL version is displayed rather than the COPY.
David
ParticipantWouldn’t it be better to code up the “Hide this widget if there are no upcoming events” property to be available to the shortcode as well as the regular widget (which the docs say it supports) ?
-
AuthorPosts
