Skip to content


Subversion checkout URL

You can clone with
Download ZIP

BBQQ Calendar

Derek Jones edited this page · 3 revisions
Clone this wiki locally


This time I'd like to add a new class called BBQQ calendar to library. I know that there is a calendar class for CodeIgniter, but this will show you how simple is to add a third party php class to CI.


Download a zip file from You need to register and sign-in in order to see a download link. Unzip it somewhere in your desktop. Open calendar.php and replace <?php with the following code at the top and save it as BBQQ_Calendar.php in application/libraries/ directory.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


Copy, paste the following code and save it as calendar.php in controllers directory.

<?php class calendar extends Controller {

function __construct() {

function index()




Copy, paste the following code and save it as calendar_view.php in views directory. Please note that I added <base href="<?=base_url();?>" /> in head section. This allows us to link a css (and javascript if you are using) file with <link href="css/example.css" media="screen" rel="stylesheet" type="text/css" >

<!DOCTYPE html><html> <head> <title>BBQQ CALENDAR</title> <base href="<?=base_url();?>" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" > <link href="css/example.css" media="screen" rel="stylesheet" type="text/css" > <body>

A plain calendar with all default settings

<?php $cal = new BBQQ_Calendar(); $cal->render(0); ?>

A plain calenar with raw output, for geektool

$cal->render(0, 1);

Customised Week Day Titles

change sun/sat to sunday/saturday

<?php $cal->setWeekDayTitle(array( 'sun' => 'Sunday', 'sat' => 'Saturday' )); $cal->render(0); ?>

Customised header

<?php $cal->render(0, 0, '

simple calendar' . ' s m t w t f s ' ); ?>

Hightlight Days With Customised Templates (Advanced Usage)

<?php $days = array( // custom template for today $cal->getToday('j') => array( 'template' => 'TODAY: :num' ), // highlight day: 5 with custom template/scripts and wrapper tag 5 => array( 'template' => ':num', 'wrapper' => array( 'tag' => 'td', 'id' => null, 'class' => 'cal-thu', 'format' => 'j F, Y', 'style' => 'color:red;background:yellow', 'onclick' => "alert('Title: ' + this.title);return false;", 'title' => ':title' ) ), // highlight day: 12 with custom template and wrapper tag 12 => array( 'template' => ':num', 'wrapper' => array( 'tag' => 'td', 'id' => null, 'class' => 'cal-thu', 'format' => 'j F, Y', 'style' => 'color:red;background:green', 'title' => 'some :title' ) ) );

$cal->highlightDays($days); $cal->render(0); ?> </body> </html>


Create a css folder as the same level as sytem, application and img folder. Find a file called example.css in the unzipped folder. Move this file to css folder.



Something went wrong with that request. Please try again.