Yii 1.1: simple-calendar

A Yii widget that draws a simple calendar. PHP only, no Javascript.
10 followers

Introduction

I was looking for a simple calendar for a project I'm working on. All I needed was something where you could navigate through the months and click on a day to select it. Unfortunately, I couldn't find a Yii extension for that, so I ended up developing one myself: Simple Calendar

Simple Calendar will render a calendar without using any client side code. Everything works with links and query string parameters.

Installation

Just extract the contents of the package to your extensions directory. Usually protect/extensions

Usage

To use it, add the following to your view:

<?php $this->widget('ext.simple-calendar.SimpleCalendarWidget'); ?>

This will render a calendar where each of the days displayed is a link in the following format:

http://example.com/current_url?month=current_month&year=current_year&day=select_day

The previous and next month links are created exactly the same way:

http://example.com/current_url?month=current_month&year=current_year&day=last_day_of_the_month

Using the query string parameters, you can get the selected date and use it wherever you need.

By default, Simple Calendar will render the calendar based on the current date. If you need it to start displaying any other date, just pass it in the widget initialization:

<?php $this->widget('ext.simple-calendar.SimpleCalendarWidget', array('year' => 2012, 'month' => 12, 'day' => 21); ?>

Recent Updates

Version 1.1
- Fixes error when current day was 30 or 31 and February was acessed
- Updated the html for the calendar to make it easier to be themed. Now you have classes for the month/year row and the for the next and previous links

Links

Total 8 comments

#18136 report it
davi_alexandre at 2014/09/15 09:19am
@Balaji S

You can't do that. The extension was developed to be totally javascript free.

#18132 report it
Balaji S at 2014/09/15 02:37am
Nice Extension

how to do next and previous month using ajax , i mean without page refresh ,

#7692 report it
@RT at 2012/04/10 02:03am
QUERY

When I am selecting date from the calendar then it will not reflect in the text box?

and calendar displayed directly while i want to keep it as a button near text box?

#5253 report it
davi_alexandre at 2011/09/26 11:39am
Re: Try out demo

Thanks @volkmar. Just fixed the problem with the demo.

#5252 report it
volkmar at 2011/09/26 11:27am
Try out demo

The demo don't work!

#4455 report it
davi_alexandre at 2011/07/10 11:51am
thanks!

@bryglen

This widget it's not intended to be used with forms. What I had in mind was something like a blog or any other kind of history where you can click on a date and see the respective items. And, of course, I didn't wanted any client side code.

@gunsnips

Theming supports is in my plans for the next release. I don't think that using same classes as the jquery ui datepicker is a good idea. E.g It will make it harder to have simple calendar and datepicker in the same page, but with different styles.

#4446 report it
Gustavo at 2011/07/10 04:11am
cool

Very nice Just a suggestion, you could use the same css classes in it as in jquery ui datepicker, allowing easy customization of its look

#4443 report it
bryglen at 2011/07/09 11:16pm
nice

it's nice but cannot be used easily in Forms since the page is reloading.

Leave a comment

Please to leave your comment.

Create extension