menu

Codeigniter Calendaring Class Library


Codeigniter Calendaring Class Library – Calendaring class library provide various functions that are used to create dynamically calendars. $this->load->library(‘calendar’); is used to load the library. This library serves to display and generate a calendar. Here in this tutorial, we are going to explain how to use calendaring class library.


Codeigniter calendaring class library.

Let us first see how to load calendaring class library and then use its function-

Load codeigniter calendaring class library

How to load calendaring class library:

Syntax of how to load this library.:-

Functions:-

There are following functions available in calendaring class library. Now we will explain one by one with example.

  • 1. Displaying a calendar
  • 2. Passing data to your calendar
  • 3. Setting display preferences
  • 4. Show next/previous month link
  • 5. Creating a calendar template

1. Displaying a calendar

Syntax of displaying a calendar is

Syntax of displaying a calendar is:-

Parameters :-

  • $year (int) : Year
  • $month (int) : Month
  • $data (array) : Data to be shown in the calendar cells
  • Returns : HTML-formatted calendar
  • Return type : String

EXAMPLE

Here is simple example of displaying a calendar.

Displaying a calendar in codeigniter Example:-

The output will be like this –

Codeigniter Calendaring Class library

2. Passing data to your calendar

EXAMPLE

Here is simple example of passing data to your calendar.

Passing data to your calendar in codeigniter example:-

The output will be like this –

Codeigniter Calendaring Class library

3. Setting display preferences

EXAMPLE

Here is simple example of setting display preferences.

Setting display preferences in codeigniter example:-

The output will be like this –

Codeigniter Calendaring Class library

4. Show next/previous month link

EXAMPLE

Here is simple example of show next/previous month link.

Show next/previous month link in codeigniter example:-

The output will be like this –

Codeigniter Calendaring Class library

5. Creating a calendar template

EXAMPLE

Here is simple example of creating a calendar template.

Creating a calendar template in codeigniter example:-

The output will be like this –

Class reference

There are following types of class reference in calendar classes.

1. Initialize

This function is used to initialize the calendar preferences and containing display preferences.

2. Generate calendar

This function is used to generate the calendar.

3. Month name

This function is used to generate text month name based on numeric month provider.

4. Day name

This function is used to make sure that you have valid month/year.

5. Get total day

This function count total days of specific month.

📖 Read More


Advertisements