如何在 codeigniter 日历中显示事件文本?

How to display events text in codeigniter calendar?

我正在使用 Codeigniter 3.0 日历库,我没有在我的 CI 日历中获取事件文本,而是在数字上显示 link 而不是显示事件文本。

示例 Codeigniter 代码:

class Welcome extends CI_Controller {

    function index()
    {
        $this->display($year = null, $month = null);
    }
     public function display($year = null, $month = null)
    {
            $config = array(
            'show_next_prev' => TRUE,
            'show_other_days' => TRUE,
            'next_prev_url' => site_url('welcome/display')
            );
            $events = array(
                1 =>'test1',
                2 =>'test2'
            );
            $this->load->library('calendar', $config);
            echo $data['calendar'] = $this->calendar->generate($year, $month, $events);

    }
}

示例日历图像(以上代码的输出):

在上面的日历中,您可以看到第 1 天和第 2 天是 linked 并且没有在日历中显示 test1test2 等事件文本,我该如何纠正这个问题?

您可以修改任何一个日历模板,更改内容并只提供数据。例如,您可以在元素内提供 title 属性,将其用作悬停时的简单工具提示,或调整 html 以提供更复杂的 ui 交互。看看:

$prefs['template'] = array(
        'cal_cell_content'       => '{content}',
        'cal_cell_content_today' => '<div class="highlight">{content}</div>'
    );
    $this->load->library('calendar', $prefs);
    $data = array(
        3  => '<a title="my event" href="http://example.com/news/article/2006/03/">My event</a>',
        7  => '<a title="conference" href="http://example.com/news/article/2006/07/">Conference</a>',
        13 => '<a title="lecture" href="http://example.com/news/article/2006/13/">Lecture</a>',
        26 => '<a title="city walk" href="http://example.com/news/article/2006/26/">City walk</a>'
    );


    echo $this->calendar->generate(2015, 6, $data);