Template Usage

Developers are able to access MegaCalendar information for use in custom built theme templates

MegaCalendar Functions

// Get the MegaCal plugin instance
$megacalblock = MegabaseCalendar::get_instance();

//Event functions:
get_title()
get_image_url()
get_event_date()
get_start_time()
get_end_time()
get_description()						
get_organizer()
get_private_note()
get_facebook_url()
get_ticket_url()
get_price_details()
get_published()
get_created_by_me()  //Is it mine or not

//Objects (Needs extra functions):
get_tagged_users()
get_owner()
get_event_category()

//Venue: 
$venue = $event->get_venue();
$venue->get_id();
$venue->get_name();
$venue->get_location();


//get permalink: 
$settings = MegabaseCalendar::megacal_get_settings();
$event_detail_path = $settings['megacal_events_url'];

MegaCalendar Template Usage

This example shows how to display MegaCalendar Events as a List from your theme template files.

<?php
$events = $megacalblock->megacal_get_public_events( array(
    'upcoming' => true,
    'max_result' => 4,
));
?>

<?php foreach( $events as $event ) { ?>
    <?php $event_date = $event->get_event_date(); ?>
    <a class="eventBox boxWrap" href="<?php echo site_url( trailingslashit( $event_detail_path ) . $event->get_id() ); ?>">
        <!-- If a Poster or Event Thumbnail Exists -->
        <?php if( !empty( $event->get_image_url() ) ): ?>
            <?php $thumbnail_src = $event->get_image_url(); ?>
            <img src="<?php echo esc_url( $thumbnail_src ); ?>" class="eventImg imgShadow alignleft" alt="<?php esc_attr_e( $event->get_title() ); ?>" />
        <?php else: ?>
            <div>
                <img src="<?php echo esc_url( megacal_get_default_event_image_path(), array( 'http', 'https' ) ); ?>" class="eventDefault artistReplace alignleft defaultPic" />
            </div>
        <?php endif; ?>
        <div class="text">
            <p class="date" title="<?php echo date('D M d, Y', strtotime( $event_date )); ?>"><?php echo date('l n/j/y', strtotime( $event_date )); ?></p>
            <p class="name"><?php esc_html_e( $event->get_title() ); ?></p>
        </div>
    </a>
<?php }  ?>

Using Custom Templates from Your Theme

You can override the template files from MegaCalendar as follows.

  • Create a folder in your active WordPress theme folder titled megabase-calendar
  • Create a sub-folder called views
  • Copy any view from the views folder located in the plugin
    • from: yoursite.com/wp-content/plugins/megabase-calendar/views/
    • to: yoursite.com/wp-content/themes/yourtheme/megabase-calendar/views/
  • The Views available to override include:
    • Standard Event List
      • Front-end Calendar View : megacal-calendar-view.php
      • Front-end Events List : megacal-full-events-list.php
    • Simplified/Compact Event List
      • megacal-compact-events-list.php
    • Simplified Event List with Pictures
      • megacal-simple-events-list.php
    • The “Wrapper” for all above Shortcode “list” views
      • megacal-events-sc-output.php
    • Event Detail View : megacal-event-detail.php