每每看到他站文章開頭都有著一本日曆來顯示發佈的日期,心中總是口水流不停,而在 Drupal 官網找版型時,通常只要有類似的畫面,不用說,馬上下載回來觀模,然而時至今日,才終於弄懂那是怎麼來的,所以趕緊寫下來,以免日後又忘了
原來很簡單,只需要先查看網頁的原始碼,然後找到發佈日期在版型檔案 node.tpl.php 中的位置,在其之前,加入如下字碼︰
<?php
$year = format_date($node->created, 'custom', 'Y');
$month = format_date($node->created, 'custom', 'M');
$day = format_date($node->created, 'custom', 'd');
?>
<div class="post-date">
<span class="post-month"><?php print $month; ?></span>
<span class="post-day"><?php print $day; ?></span>
<span class="post-year"><?php print $year; ?></span></div>