My Calendar’s PHP templates are context sensitive, allowing you to display the event content differently in different contexts. There are five primary content templates:

  • calendar.php
    • Structure the content body as shown in the Grid view of the calendar modal or pop-up.
  • card.php
    • Structure the content body as shown in the Card view of the calendar.
  • list.php
    • Structure the content body as shown in the List view of the calendar modal or pop-up.
  • mini.php
    • Structure the content body as shown in the Mini view of the calendar modal or pop-up..
  • single.php
    • Structure the content body as shown in the Single views of the calendar.

The default content templates for these views respect the settings used at My Calendar > Settings > Display > Event Display Fields. If you have disabled fields using those settings, they will still be disabled using PHP templates. In the old view system, there was no distinction between List and Grid pop-ups.

They also respect existing custom templates, defined at My Calendar > Design > Templates; although if you enable PHP templates, you’ll lose access to editing those custom templates. This is because the main benefit of PHP templates is that you can use logic in your custom templates, and that you can maintain your custom templates in version control tools such as Github.

If you don’t intend to take advantage of those benefits, there’s no particular reason to use the PHP templates.

There are also five content templates for managing other shortcode or widget driven views:

  • now.php
    • Structure the output of the [my_calendar_now] shortcode, which shows the first event that is currently showing.
  • next.php
    • Structure the output of the [my_calendar_next] shortcode, which shows the next event.
  • search.php
    • Structure the event display in search results.
  • today.php
    • Structure the output of the [my_calendar_today] shortcode, which shows a list of events happening today.
  • upcoming.php
    • Structure the output of the [my_calendar_upcoming] shortcode, which shows a list of future events. (Or can show a list of past events, if you choose to configure it that way.)

All of these shortcodes or widgets have existing mechanisms to define a template within the shortcode or by requesting a shortcode created in the custom template settings under My Calendar > Design > Templates.

Any custom template already defined will be rendered by the PHP templates, but the settings to create new non-PHP templates will be disabled.

Example custom template

<div class="mc-event-container">
	<div class="mc-image-container">
		<a href="<?php mc_template_tag( $data, 'details_link' ); ?>"><?php mc_template_image( $data, 'card' ); ?></a>
	</div>
	<div class="mc-content-container">
		<div class="mc-card-date">
			<?php mc_template_tag( $data, 'datebadge' ); ?>
		</div>
		<div class="mc-card-content">
			<h3><a href="<?php mc_template_tag( $data, 'details_link' ); ?>"><?php mc_template_tag( $data, 'title' ); ?></a></h3>
			<div class="excerpt">
				<p><?php mc_template_tag( $data, 'auto_excerpt' ); ?></p>
			</div>
			<div class="custom-content">
				<?php your_custom_handler( $data ); ?>
			</div>
		</div>
	</div>
</div>

This example template is intended for use in card output, and includes a hypothetical custom function. One of the advantages to custom PHP templates is that it makes it easier for you to author custom templating functions that can take My Calendar data and use it in more custom ways.