Skip to content

Instantly share code, notes, and snippets.

@jasonvarga
Last active October 2, 2015 19:48
Show Gist options
  • Save jasonvarga/823c05bc6231350fab73 to your computer and use it in GitHub Desktop.
Save jasonvarga/823c05bc6231350fab73 to your computer and use it in GitHub Desktop.
Creating a single page dynamic URL calendar. This assumes a URL scheme like /calendar/month/2015/01
{{ calendar:set_month folder="calendar" year="{ segment_3 }" month="{ segment_4 }" }}
<h1>{{ calendar:month_name }} {{ segment_3 }}</h1>
{{ calendar:prev_month }}
<a href="/calendar/month/{{ year }}/{{ month }}" title="{{ month_name }} {{ year }}">&larr; Prev</a>
{{ /calendar:prev_month }}
{{ calendar:date_select attr="id:month-select" }}
{{ calendar:next_month }}
<a href="/calendar/month/{{ year }}/{{ month }}" title="{{ month_name }} {{ year }}">Next &rarr;</a>
{{ /calendar:next_month }}
{{ calendar:month folder="calendar" inherit="true" }}
<table>
<thead>
<tr>
{{ days_of_week }}
<th>{{ day_name }}</th>
{{ /days_of_week }}
</tr>
</thead>
<tbody>
{{ weeks }}
<tr>
{{ days }}
<td class="{{ if other_month }}other-month{{ endif }} {{ if today }}today{{ endif }}">
<small>{{ day }}</small>
{{ entries }}
<div class="event {{ if all_day }}all-day{{ endif }}">
{{ unless all_day }}
<b>{{ start_time }}{{ if end_time }} - {{ end_time }}{{ endif }}:</b>
{{ endif }}
{{ title }}
</div>
{{ /entries }}
</td>
{{ /days }}
</tr>
{{ /weeks }}
</tbody>
</table>
{{ /calendar:month }}
<script src="jquery.js"></script>
<script>
$('#month-select').on('change', function() {
window.location = '/calendar/month/' + $(this).val();
});
</script>
routes:
/calendar/month/*: calendar_month
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment