CodeIgniter from Scratch: The Calendar Library
videos

CodeIgniter from Scratch: The Calendar Library

Share

In this tenth episode of the CodeIgniter From Scratch screencast series, we will be exploring the Calendar library. We are also going to utilize the database class and jQuery AJAX. I will show you how to build a simple and CSS-styled calendar page, which will have the ability to store and display content for each day.

Final Example

Catch Up

Day 10: The Calendar Library

Other Viewing Options

Related Posts

Add Comment

Discussion 118 Comments

Comment Page 2 of 2 1 2
  1. Rebornmx says:

    Thanks, very useful, maybe you could make a Facebook – CodeIgniter integration or a Star Rating System using CodeIgniter tutorial.

  2. Achref says:

    Plz can’t you put the database of this project.

  3. Hello

    Great Job..
    Looking very nice.

    Better to place database script in the download.

    cheers :)

    Krishna Mohan L V

  4. Desu says:

    Thank you for the available link to download the mp4 file. Its hard to me to watch the video online (in slow connection), so I need to download the file then watch on my PC. Very useful tutorial for me :D

  5. BrandonLee says:

    Great programing! What do I need to do to get more events onto 1 cell/day? Since the key is the day, the key has to be unique. What would be an elegant way to show multiple events for 1 day?

    • Bryan Dease says:

      In order to pull that off in a nice way – I actually modified the calendar library a bit. The standard gives you a good bit of control – but still can be somewhat limiting. Here’s what I have come up with that shows events spanning multiple days and can also cover the same days as well.

      http://ttgdev.com/marsmedia/calendar/display/2010/06

      Bryan

      • Josh Bright says:

        Hey, the multiple day spanning deal on that calendar looks pretty slick, do you have any code anywhere that we can look at for that?

      • Bryan Dease says:

        Sure – give me a day or 2 and I will throw it together and give you a url. Trying to finish up the whole calendar :)

      • Mogetutu says:

        I wouldn’t mind getting a look and taking it for a test run.

        Good things happening!

  6. bill mc says:

    This is odd, I can’t display any items for day_num values 1 to 9 … no single digit days.
    I checked, the calendar events for those days are recorded in the database.
    The data does appear in $cal_data being passed to $this->calendar->generate($year, $month, $cal_data);

    But the resulting string does not include the calendar events for days 1 to 9.

    Anyone else get this?

    • bill mc says:

      In the model, in function get_calendar_data, you have to strip off the leading ’0′ where applicable.

      • bill mc says:

        My solution:

        function get_calendar_data($year, $month) {

        $query = $this->db->select(‘date, data’)->from(‘sys_calendar’)
        ->like(‘date’, “$year-$month”, ‘after’)->get();

        $cal_data = array();

        foreach ($query->result() as $key=>$row) {
        $cal_data[substr($row->date,8,2) + 0] = $row->data;
        }

        return $cal_data;

        }

        Adding a ’0′ in the cal_data assignment has the effect of converting the string ’01′ to the number ’1′ … solving the problem.

        Hope that helps someone else.

      • Michael says:

        thx a lot, this solved my problem ;) hope codeigniter will fix this in the next release

  7. sharoni says:

    Or you can use phps intval() function to the substr($row->date, 8, 2);

    cheers

  8. karrot_komsai says:

    big Thanks for the intval()!

    Btw, entries would still not be removed unless accessed via a db manager like phpmyadmin (suppose you wish to delete a note by replacing it with a null value). The calendar would look empty but if you’ll scan the db, the entry is still there (with a null data value). maybe you could add a function that deletes the entry in case a null value is entered.

  9. Russ says:

    I changed my database structure so that I could enter multiple things for any one given date. My calendar is only displaying the most recent entry in my table. Can someone point me in the right direction as to what needs to change in the get_calendar_data function for multiple entries to display? Thanks!

  10. woony says:

    I’m having a problem passing my config to the library. It just doesn’t seems to load it… anything I put in config it has no effect… any ideas what I could be doing wrong?

  11. Andy says:

    Thanks Burak,
    Another great tutorial! I have it working perfectly in firefox/ safari but for some reason ie won’t do the post? Any ideas anyone?
    I’m running Codeigniter on MAMP and IE is on windows in a Virtual Machine. Firefox in the same VM works fine.

    I thought at first it might be something to do with the prompt so I created a modal to hold a form but still no dice.

    I’m really stuck for ideas now so any help would be gratefully received!

  12. Eoghan says:

    Many thanks Burak, a terrific turtorial.

  13. For those of you who dont know what to put in the ‘calendar’ table for this database, let me tell you it is very simple.

    I am assuming that you are using WAMP, though this should work wherever you have phpMyAdmin installed.

    Start phpMyAdmin, create a database ‘ci_series’.

    Create a table ‘calendar’.

    Have 2 columns: 1st named ‘date’ with type ‘DATE’
    2nd named ‘data’ with type ‘VARCHAR’ and length about 100.

    And then save the table.

    And then just run the source code that you get from above, thanks to Burak.

    Cheers,

    Rishi.

  14. ci9 says:

    @burak

    Thank you very much for this very very nice tutorial.

    God Bless you and Thank you!

  15. ramesh says:

    thanks a lot….. may god bless tutplus network

  16. devlim says:

    the tutorial is php4 oop, i change to php 5 oop, seem like we cannot use $config word as our config variable , it generate error, must use any other than $config.

    wao! waste so much time to figure wat wrong wif my code…

  17. devlim says:

    does it work for day which range from 1-9?
    i cant get it work by entering the data, the tutorial also aim at day range from 10-31 only,

    so anyone? or i make mistake?

Comment Page 2 of 2 1 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.