Permalink
Browse files

Loads more examples added.

  • Loading branch information...
alexgisby committed Feb 19, 2011
1 parent 726bfec commit 5c643a9eac76e148426276d62a0b73300ad46a08
Showing with 62 additions and 2 deletions.
  1. +35 −0 classes/controller/kcalexamples.php
  2. +1 −1 views/kcal/cell.html
  3. +5 −0 views/kcalexamples/index.html
  4. +21 −1 views/kcalexamples/kcalpage.html
@@ -23,5 +23,40 @@ public function action_index()
// Using a custom date;
$date_cal = new kCal(12, 5, 2014); // Notice how the month is an integer, not a string!
$this->template->date_calendar = $date_cal;
+
+ // With events;
+ $event_cal = new kCal(1, 2, 2011);
+
+ // The two strings are the start and end dates and should be in a strtotime friendly format.
+ $event_cal->add_event('1 February 2011 08:30', '1 February 2011 09:30', array(
+ // This array can contain absolutely anything. The data will be passed to the template
+ // so you can display the correct information.
+ 'title' => 'Early Morning Run',
+ 'url' => '/events/early-morning-run',
+ 'style' => 'red',
+ ));
+
+ // Events can span several days;
+ $event_cal->add_event('14 February 2011 12:35', '18 February 2011 12:00', array(
+ 'title' => 'Camp Crunchalot',
+ 'url' => '/events/camp-crunchalot',
+ 'style' => 'green',
+ ));
+
+ // They can even go outside the 'bounds' of the month;
+ $event_cal->add_event('26 February 2011 12:35', '10 March 2011 12:00', array(
+ 'title' => 'Bike Tour',
+ 'url' => '/events/bike-tour',
+ 'style' => 'blue',
+ ));
+
+ // And finally, you can of course have multiple events per day;
+ $event_cal->add_event('17 February 2011 10:00', '17 February 2011 15:00', array(
+ 'title' => 'Gym Session',
+ 'url' => '/events/gym-session',
+ 'style' => 'red',
+ ));
+
+ $this->template->event_calendar = $event_cal;
}
}
View
@@ -4,7 +4,7 @@
{% if cell.has_events %}
<div class="events">
{% for event in cell.events %}
- <a href="{{ event.url }}" title="{{ event.long_title }}" id="tip_trigger_{{ cell.idx }}" class="tip_trigger calendar_event {{ event.style }}">{{ event.title }}</a>
+ <a href="{{ event.url }}" class="calendar_event {{ event.style }}">{{ event.title }}</a>
{% endfor %}
</div>
{% endif %}
@@ -13,4 +13,9 @@ <h1>With a specific date</h1>
{{ date_calendar }}
{% endautoescape %}
+ <h1>With events</h1>
+ {% autoescape off %}
+ {{ event_calendar }}
+ {% endautoescape %}
+
{% endblock %}
@@ -21,11 +21,31 @@
padding: 5px;
}
+ .calendar td {
+ border: 1px solid #ccc;
+ width: 14%;
+ }
+
.calendar td.today {
background-color: #F0CA9F;
}
-/* .calendar td.*/
+ .calendar .calendar_event {
+ display: block;
+ padding: 3px 6px;
+ }
+
+ .calendar .calendar_event.red {
+ background-color: #fcc;
+ }
+
+ .calendar .calendar_event.green {
+ background-color: #cfc;
+ }
+
+ .calendar .calendar_event.blue {
+ background-color: #ccf;
+ }
</style>
</head>

0 comments on commit 5c643a9

Please sign in to comment.