Getting the year/month/day as a link in codeigniter calendar class

血红的双手。 提交于 2019-12-08 12:46:44

问题


Im trying to convert the a day to a link if there are any content so the format will be.

site/calendar/2012/1/2

so i will be able to retrieve the information that is relevant.

in my model in have the template and the other options,

Model

and

Controller

can someone please tell me how can i get the dates as year/month/day to the so i can retrieve the values.

<div class="content"><a href="year/month/{day}">View</a></div>

回答1:


You're setting the month and year in your view method, so you could just pass those to the view through the $data array:

// Diary Controller
$data['calendar'] = $this->diary_model->generate($year, $month);
$data['year'] = $year; // ADD THIS
$data['month'] = $month; // ADD THIS

$data['body']='diary/calender';

$this->load->view('includes/template', $data);

then, in your model you can set it like this:

// Diary Model
$this->conf['template'] = '...
{cal_cell_content}
  <div class="day_num">{day}</div>
  <div class="content"><a href="'.$year.'/'.$month.'/{day}">View</a></div>
{/cal_cell_content}
...';


来源:https://stackoverflow.com/questions/8727504/getting-the-year-month-day-as-a-link-in-codeigniter-calendar-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!