获取年/月/日作为 codeigniter 日历类中的链接

发布于 2024-12-24 22:38:44 字数 418 浏览 1 评论 0原文

我正在尝试将一天转换为链接(如果有任何内容),因此格式将是。

site/calendar/2012/1/2

这样我就能够检索相关的信息。

在我的模型中有模板和其他选项,

模型

控制器

有人可以告诉我如何获取年/月/日的日期,以便我可以检索值。

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈年往事 2024-12-31 22:38:44

您在 view 方法中设置月份和年份,因此您可以通过 $data 数组将它们传递给视图:

// 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);

然后,在模型中您可以设置像这样:

// 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}
...';

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}
...';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文