Home › Forums › Calendar Products › Events Calendar PRO › Hide Calendar Widget when no events?
- This topic has 3 replies, 2 voices, and was last updated 9 years, 5 months ago by Brian.
-
AuthorPosts
-
November 3, 2014 at 12:48 pm #858453Christopher Liu-BeersParticipant
Is it possible to either hide the calendar widget entirely or display a custom message when there are no upcoming events?
November 3, 2014 at 4:27 pm #858744BrianKeymasterHi,
I can help you out with this. There is not option like on the Upcoming Events List Widget to hide if no events.
With a simple function you can add your own to the Calendar Widget though.
You could follow our Themer’s Guide:
https://theeventscalendar.com/support/documentation/events-calendar-themers-guide/
To move this file to your theme:
\events-calendar-pro\views\pro\widgets\mini-calendar-widget.php
Then use this function to wrap the Calendar Widget and if Display a Message if you like in the else statement.
https://gist.github.com/jesseeproductions/739c9a0c00f494ccc0d7
Let me know if you have any followup questions.
Thanks
November 4, 2014 at 7:19 am #859920Christopher Liu-BeersParticipantExcellent – this worked for me with some modification. I’ll post the code in case this helps anyone else…
/**
* Events Pro Mini Calendar Widget
* This is the template for the output of the mini calendar widget.
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/widgets/mini-calendar-widget.php
*
* @package TribeEventsCalendarPro
*
*/if ( !defined('ABSPATH') ) { die('-1'); } ?>
'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'mountains' ))));$triangle_events = tribe_get_events(array('eventDisplay'=>'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'triangle' ))));$trid_events = tribe_get_events(array('eventDisplay'=>'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'triad' ))));$metrolina_events = tribe_get_events(array('eventDisplay'=>'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'metrolina' ))));$sandhills_events = tribe_get_events(array('eventDisplay'=>'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'sandhills' ))));$coast_events = tribe_get_events(array('eventDisplay'=>'upcoming', 'tax_query'=> array( array( 'taxonomy' => 'region', 'field' => 'slug',
'terms' => 'coast' ))));//If there are any events, show the calendar widget on a specific page
if ( (count( $mountains_events ) > 0) && is_page( 3054 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }if ( (count( $triangle_events ) > 0) && is_page( 3060 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }if ( (count( $triad_events ) > 0) && is_page( 3058 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }if ( (count( $metrolina_events ) > 0) && is_page( 3056 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }if ( (count( $sandhills_events ) > 0) && is_page( 3062 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }if ( (count( $coast_events ) > 0) && is_page( 3064 )) {
tribe_show_month( array(
'tax_query' => $args['tax_query'],
'eventDate' => $args['eventDate'],
), 'pro/widgets/mini-calendar/grid' ); }?>
0) && is_page( 3054 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}elseif ( (count( $triangle_events ) > 0) && is_page( 3060 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}elseif ( (count( $triad_events ) > 0) && is_page( 3058 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}elseif ( (count( $metrolina_events ) > 0) && is_page( 3056 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}elseif ( (count( $sandhills_events ) > 0) && is_page( 3062 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}elseif ( (count( $coast_events ) > 0) && is_page( 3064 ) ) {
tribe_get_template_part( 'pro/widgets/mini-calendar/list' );
}else {
echo "No events at this time. Click here to view all events. Click here to add an event to the calendar.";
}
?>November 4, 2014 at 8:15 am #860020BrianKeymasterGreat glad it helps. I edited the coding a bit to remove the links and place it in our code wrapper to help out.
I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.
Thanks
-
AuthorPosts
- The topic ‘Hide Calendar Widget when no events?’ is closed to new replies.