求日历类扩展
要求是这样的:点击上一个月或下一个月链接的时候,号数有不同的链接,比如说3月份有12,22,25号是有活动的,就有链接,4月有11,15号是有活动的,也相应的标有链接,请教大侠应该如何扩展日历类,在线等。。。。。。 传数据到单元格增加数据到日历的单元格就要创建一个关联数组,在这个数组中索引是你想链接的天数value值包含你要传入的值.数组通过日历创建函数的第三个参数被传入. 参考下面这个例子:$date_time = time();$year= ($this->uri->segment(2) == 'archive') ? $this->uri->segment(3) : date("Y", $date_time);
$month = ($this->uri->segment(2) == 'archive') ? $this->uri->segment(4) : date("m", $date_time);
$data = $this->get_calendar_data($year, $month);
比如返回的data如下
$data = array(
3=> 'http://example.com/news/article/2006/03/',
7=> 'http://example.com/news/article/2006/07/',
13 => 'http://example.com/news/article/2006/13/',
26 => 'http://example.com/news/article/2006/26/'
);$this->load->library('calendar');
echo $this->calendar->generate($year, $month, $data);使用上面的例子,天数3,7,13和26将变成链接指向你提供的URLs. 请问怎样才能让$data = $this->get_calendar_data($year, $month);的$data返回的是这个样子的
$data = array(
3=> 'http://example.com/news/article/2006/03/',
7=> 'http://example.com/news/article/2006/07/',
13 => 'http://example.com/news/article/2006/13/',
26 => 'http://example.com/news/article/2006/26/'
);
请教这个方法$this->get_calendar_data($year, $month)是如何写的能举个例子吗 非常感谢 /**
* 返回日历上的存档链接
* @access public
* @param integer $year
* @param integer $month
* @return array
*/
public function get_calendar_data($year, $month)
{
$time_start = mktime(0, 0, 0, $month, 1, $year);
$time_end = mktime(0, 0, 0, $month+1, 1, $year);
$this->db->select('create_date');
$this->db->from('news');
$this->db->where('create_date >=', $time_start);
$this->db->where('create_date <', $time_end);
$cal_res = $this->db->get()->result_array();
$cal_url = array();
foreach(array_keys($cal_res) as $key)
{
$cal_date = $cal_res[$key]['create_date'];
$cal_url = site_url('news/article/'.date('Y/n/', $cal_date));
}
return $cal_url;
}
本帖最后由 Crazy 于 2010-3-30 01:36 编辑
问题已经解决,非常感谢楼上的大哥。:handshake 这个帖子学到东西了,thx:lol 学习了 :lol学习了 标记一下! huboo82 发表于 2010-3-16 13:47 static/image/common/back.gif
传数据到单元格增加数据到日历的单元格就要创建一个关联数组,在这个数组中索引是你想链接的天数value值包含 ...
好,很好!支持:curse:
页:
[1]