我正在寻找一种在日历上显示周数的方法。 现在,我发送年份和月份来创建日历。如果需要更多日历,我会在视图上重复代码。
我在控制器上使用以下首选项。
$prefs = array(
'start_day' => 'monday',
'month_type' => 'long',
'day_type' => 'abr'
);
查看:
$thisyear = $todaysdate->format('Y');
$thismonth = $todaysdate->format('m');
echo $this->calendar->generate($thisyear,$thismonth++);
知道如何做到这一点吗?
@The End I need:
2017四月
|我们|莫|涂|我们|钍| FR | SA |苏
| 13 | | | | | | | 1 | 2 |
| 14 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 15 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 17 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
答案 0 :(得分:1)
CI_Calendar
不支持此功能,抱歉。
除非您覆盖整个库,否则无法添加它,此时您应该使用其他内容。
答案 1 :(得分:1)
$("table tr").each(function() {
var myTd = $(this).find("td");
var myContent = myTd.find("div[data-content]").data("content");
if(myContent != undefined) {
$(myTd).first().text(myContent);
}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<table>
<tbody>
<tr>
<th></th>
<th colspan="7">Aprile 2017</th>
</tr>
<tr>
<td>We</td>
<td>Lu</td>
<td>Ma</td>
<td>Me</td>
<td>Gi</td>
<td>Ve</td>
<td>Sa</td>
<td>Do</td>
</tr>
<tr>
<td></td>
<td><div> </div></td>
<td><div> </div></td>
<td><div> </div></td>
<td><div> </div></td>
<td><div> </div></td>
<td>
<div data-content="13">1</div>
</td>
<td>
<div data-content="13">2</div>
</td>
</tr>
<tr>
<td></td>
<td>
<div data-content="14">3</div>
</td>
<td>
<div data-content="14">4</div>
</td>
<td>
<div data-content="14">5</div>
</td>
<td>
<div data-content="14">6</div>
</td>
<td>
<div data-content="14">7</div>
</td>
<td>
<div data-content="14">8</div>
</td>
<td>
<div data-content="14">9</div>
</td>
</tr>
<tr>
<td></td>
<td>
<div data-content="15">10</div>
</td><td>
<div data-content="15">11</div>
</td><td>
<div data-content="15">12</div>
</td><td>
<div data-content="15">13</div>
</td><td>
<div data-content="15">14</div>
</td><td>
<div data-content="15">15</div>
</td><td>
<div data-content="15">16</div>
</td>
</tr>
<tr>
<td></td>
<td>
<div data-content="16">17</div>
</td><td>
<div data-content="16">18</div>
</td><td>
<div data-content="16">19</div>
</td><td>
<div data-content="16">20</div>
</td><td>
<div data-content="16">21</div>
</td><td>
<div data-content="16">22</div>
</td><td>
<div data-content="16">23</div>
</td>
</tr>
<tr>
<td></td>
<td>
<div data-content="17">24</div>
</td><td>
<div data-content="17">25</div>
</td><td>
<div data-content="17">26</div>
</td><td>
<div data-content="17">27</div>
</td><td>
<div data-content="17">28</div>
</td><td>
<div data-content="17">29</div>
</td><td>
<div data-content="17">30</div>
</td>
</tr>
</tbody>
</table>
根据您拥有的资源,javascript,jQuery等,您可以进行一些破解。
使用此代码,您可以生成一个带有周数的日历,例如每个TD上的参数“data-content”和周数的添加列。 然后你可以使用jQuery将周值放在正确的TD上。
$this->load->library('calendar', array (
'template' => '
{table_open}<table>{/table_open}
{heading_row_start}<tr>{/heading_row_start}
{heading_previous_cell}<th><a href="{previous_url}"><<</a></th>{/heading_previous_cell}
{heading_title_cell}<th></th><th colspan="{colspan}">{heading}</th>{/heading_title_cell}
{heading_next_cell}<th><a href="{next_url}">>></a></th>{/heading_next_cell}
{heading_row_end}</tr>{/heading_row_end}
{week_row_start}<tr><td>We</td>{/week_row_start}
{week_day_cell}<td>{week_day}</td>{/week_day_cell}
{week_row_end}</tr>{/week_row_end}
{cal_row_start}<tr><td></td>{/cal_row_start}
{cal_cell_start}<td>{/cal_cell_start}
{cal_cell_content}
<div data-content="{content}">{day}</div>
{/cal_cell_content}
{cal_cell_content_today}
<div data-content="{content}">{day}</div>
{/cal_cell_content_today}
{cal_cell_no_content}{day}{/cal_cell_no_content}
{cal_cell_no_content_today}<div>{day}</div>{/cal_cell_no_content_today}
{cal_cell_blank}<div> </div>{/cal_cell_blank}
{cal_cell_end}</td>{/cal_cell_end}
{cal_row_end}</tr>{/cal_row_end}
{table_close}</table>{/table_close}',
'start_day' => 'monday',
'month_type' => 'long',
'day_type' => 'abr',
'show_next_prev' => FALSE));
list($num_days, $month, $year) = explode(' ', date("t n Y"));
$array_days = [];
for ($i = 1; $i <= $num_days; $i++)
{
$week = (int)date('W', mktime(0, 0, 0, $month, $i, $year));
$array_days[$i] = "$week";
}
echo $this->calendar->generate($year, $month, $array_days);
答案 2 :(得分:1)
CI日历中没有周数的选项。