Skip to content

Instantly share code, notes, and snippets.

@delamedia
Created July 16, 2012 20:10
Show Gist options
  • Save delamedia/3124739 to your computer and use it in GitHub Desktop.
Save delamedia/3124739 to your computer and use it in GitHub Desktop.
PHP in Events
<?php
$_GET['cal_id'] = (isset($_GET['cal_id'])) ? $_GET['cal_id'] : '';
$_GET['event_id'] = (isset($_GET['event_id'])) ? $_GET['event_id'] : '';
?>
<?php if( empty($_GET['cal_id']) ) : ?>
{!-- the links from the old site didn't use cal_id or event_id. this will preserve their functionality --}
{if segment_3}
{exp:calendar:calendars calendar_name="{segment_3}" }
{redirect="events/detail/{calendar_url_title}?cal_id={calendar_id}"}
{/exp:calendar:calendars}
{/if}
<?php elseif( empty($_GET['event_id']) ) : ?>
{!-- preserve the old links and enable the "recommended classes" to work without the event_id --}
{exp:calendar:events calendar_id="{get:cal_id}" date_range_start="today" date_range_end="1 year"}
{occurrences limit="1"}
{redirect="events/detail/{calendar_url_title}?cal_id={calendar_id}&event_id={event_id}"}
{/occurrences}
{/exp:calendar:events}
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment