1
I made a method that writes a VIEW with a calendar table that shows every month of a year using the library Calendaring Class. It works well, and returns it:
Code:
<?php
class Calendar extends CI_Controller {
public function this_year() {
$data['title'] = 'Calendar: ' . date('Y');
$this->load->library('calendar');
$prefs = array(
'local_time' => 'none',
'start_day' => 'sunday',
'month_type' => 'long',
'day_type' => 'short',
'show_next_prev' => FALSE,
'show_other_days' => TRUE,
'template' => '
{table_open}<table class="table table-condensed">{/table_open}
{heading_row_start}<tr class="info">{/heading_row_start}
{cal_cell_start_today}<td class="today">{/cal_cell_start_today}
{cal_cell_start_other}<td class="other-day">{/cal_cell_start_other}
'
);
$this->load->library('calendar', $prefs);
$data['calendar'] = '<table class="table-calendar"><tr>';
for ($i = 1; $i <= 12; $i++) {
if ($i % 3 == 0) {
$data['calendar'].= "<td>{$this->calendar->generate(date('Y'), $i)}</td>";
$data['calendar'].= '</tr><tr>';
}
else {
$data['calendar'].= "<td>{$this->calendar->generate(date('Y'), $i)}</td>";
}
}
$data['calendar'].= '</tr></table>';
$this->template->load('template/index', __CLASS__ . "/" . __FUNCTION__, $data);
}
}
But I couldn’t find a way to highlight just the current month using a template in the table’s CSS. When I change line style {heading_row_start}<tr>{/heading_row_start}
(ref), it modifies all month labels:
I’m using the methods and patterns of basic tutorial (same code). Any suggestions?
In fact, I was focused on changing the style of the line
{heading_row_start}<tr>{/heading_row_start}
I did not notice that it is more practical to change the table where the month is generated. I also came up with a solution extending the Ci_calendar class, but I will mark your answer because it is a simpler solution. Thank you!– ShutUpMagda