Getting the year/month/day as a link in codeignite

2019-06-14 05:05发布

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条回答
等我变得足够好
2楼-- · 2019-06-14 05:34

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}
...';
查看更多
登录 后发表回答