Viewing two months at once as the default view

With the calendar view, if we have an event on the first day of the next month, people won't see it on the main page until the day of. Is there a way to:

1. Show the next six weeks? That would be ideal. If not, then...
2. Show the next month's calendar below the current one? If not, and we're really downgrading now, then...
3. Show list view.

  • Vladislav

    Hi,

    Showing more then one month's events in one calendar view wouldn't really be possible, as the days count and weekdays differ. It would be, however, possible to show more then one calendar instance (say, for this month's events and for the next month). You can do this by copying over the "default-templates/calendar/archive-incsub_event.php" file to your theme's root folder and editing it to allow for this. Adding something like this to the template will show the table with events for the next month:

    <?php
    	$next_month = strtotime("+1 month", $time);
    	$events = Eab_CollectionFactory::get_upcoming_events($next_month);
    	$renderer = new Eab_CalendarTable_EventArchiveCalendar($events);
    	echo $renderer->get_month_calendar($next_month);
    ?>

    In the same file, you can also tweak the navigation links position.

  • tuxkapono

    Thanks Timothy,

    I gave it a shot. Below is the inserted code in the archive-incsub_event.php file which I copied over to the root folder (see screenshot). Is that it?

    <?php
    global $booking, $wpdb, $wp_query;
    $year = $wp_query->query_vars['event_year'];
    $year = $year ? $year : date_i18n('Y'); // date_i18n uses current_time when called like this
    $month = $wp_query->query_vars['event_monthnum'];
    $month = $month ? $month : date_i18n('m');
    $time = strtotime(&quot;{$year}-{$month}-01&quot;);
    
    get_header( 'event' );
    ?>
    	<div id=&quot;primary&quot;>
            <div id=&quot;wpmudevevents-wrapper&quot;>
                <h2><?php echo sprintf(
                	__('Events for %s', Eab_EventsHub::TEXT_DOMAIN),
                	date_i18n(&quot;F Y&quot;, $time)
    			); ?></h2>
                <div class=&quot;wpmudevevents-list&quot;>
                <?php
                	if (!class_exists('Eab_CalendarTable_EventArchiveCalendar')) require_once EAB_PLUGIN_DIR . 'lib/class_eab_calendar_helper.php';
    				$renderer = new Eab_CalendarTable_EventArchiveCalendar($wp_query->posts);
    				echo $renderer->get_month_calendar($time);
                ?>
    
    				<div class=&quot;event-pagination&quot;>
    					<?php
    						$prev = $time - (28*86400);
    						$next = $time + (32*86400);
    					?>
    					<a href=&quot;<?php echo Eab_Template::get_archive_url($prev, true); ?>&quot;>Prev</a>
    					<a href=&quot;<?php echo Eab_Template::get_archive_url($next, true); ?>&quot;>Next</a>
    				</div>
    			</div>
    		</div>
    	</div>
    
    $next_month = strtotime(&quot;+1 month&quot;, $time);
    	$events = Eab_CollectionFactory::get_upcoming_events($next_month);
    	$renderer = new Eab_CalendarTable_EventArchiveCalendar($events);
    	echo $renderer->get_month_calendar($next_month);
    
    <?php get_footer( 'event' ); ?>

  • Vladislav

    Hi,

    You'll want to also wrap the code for your new calendar table in "<?php ... ?>" tags - so it reads like:

    <?php
    $next_month = strtotime('+1 month', $time);
    $events = Eab_CollectionFactory::get_upcoming_events($next_month);
    $renderer = new Eab_CalendarTable_EventArchiveCalendar($events);
    echo $renderer->get_month_calendar($next_month);
    ?>

    Depending on your site layout and style, you may also optionally want to wrap the part within "<?php ... ?>" tags with some divs, for appearance sake - but that's entirely optional.

  • tuxkapono

    Thanks Vladislav, I really appreciate the feedback.

    Here's the code, but I don't see the changes at visualizenashua.com/events. I'll play with the divs once I get past this step :slight_smile:

    <?php
    global $booking, $wpdb, $wp_query;
    $year = $wp_query->query_vars['event_year'];
    $year = $year ? $year : date_i18n('Y'); // date_i18n uses current_time when called like this
    $month = $wp_query->query_vars['event_monthnum'];
    $month = $month ? $month : date_i18n('m');
    $time = strtotime("{$year}-{$month}-01");
    
    get_header( 'event' );
    ?>
    	<div id="primary">
            <div id="wpmudevevents-wrapper">
                <h2><?php echo sprintf(
                	__('Events for %s', Eab_EventsHub::TEXT_DOMAIN),
                	date_i18n("F Y", $time)
    			); ?></h2>
                <div class="wpmudevevents-list">
                <?php
                	if (!class_exists('Eab_CalendarTable_EventArchiveCalendar')) require_once EAB_PLUGIN_DIR . 'lib/class_eab_calendar_helper.php';
    				$renderer = new Eab_CalendarTable_EventArchiveCalendar($wp_query->posts);
    				echo $renderer->get_month_calendar($time);
                ?>
    
    				<div class="event-pagination">
    					<?php
    						$prev = $time - (28*86400);
    						$next = $time + (32*86400);
    					?>
    					<a href="<?php echo Eab_Template::get_archive_url($prev, true); ?>">Prev</a>
    					<a href="<?php echo Eab_Template::get_archive_url($next, true); ?>">Next</a>
    				</div>
    			</div>
    		</div>
    	</div>
    
    <?php
    $next_month = strtotime('+1 month', $time);
    $events = Eab_CollectionFactory::get_upcoming_events($next_month);
    $renderer = new Eab_CalendarTable_EventArchiveCalendar($events);
    echo $renderer->get_month_calendar($next_month);
    ?>
    
    <?php get_footer( 'event' ); ?>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.