列表页时间日期标签靠显示html,帝国CMS列表页面list.var分别调用年月日,显示个性时间日期...
在帝國CMS中列表頁個性時間顯示的實現方式,首先我們要知道用什么方法來實現,這里我們使用PHP代碼來做。
要在模板代碼中使用PHP代碼,就必須勾選此模板代碼頁面的-使用程序代碼.位置就在添加模板頁面的列表內容模板(list.var) (*)上邊。
然后我們在list.var里邊用PHP代碼來實現我們的調用。
list.var使用PHP代碼有幾個規則
1、增加模板時list.var模板需要勾選“使用程序代碼”選項。如圖:
2、直接添加PHP代碼,不需要加<?和 ?>程序開始和結束標記。
3、字段值數組變量為$r,對應的字段變量為$r[字段名],如:標題字段變量就是$r[title]。另外編號變量為$no
4、將最終模板內容賦給$listtemp變量。
例子2:如果信息是今天發布的就顯示“NEW”圖片標識。
$newimg='';
if(time()-$r[newstime]<=1*24*3600)
{
$newimg='';
}
$listtemp='
[!--title--] '.$newimg.'';上邊將了在list.var中使用PHP規則,下邊繼續看我們的日期怎么實現。
我們在list.var中先使用以下代碼分別獲取年、月、日等
$newstime=$r[newstime];//獲取信息發布時間
$year=format_datetime($newstime,"Y");//單獨獲取年
$month=format_datetime($newstime,"m");//單獨獲取月
$day=format_datetime($newstime,"d");//單獨獲取日
然后在需要的地方添加
年:'.$year.'
月:'.$month.'
日:'.$day.'
自己按需調用即可。
所以list.var中的完整代碼就是
$newstime=$r[newstime];//獲取信息發布時間
$year=format_datetime($newstime,"Y");//單獨獲取年
$month=format_datetime($newstime,"M");//單獨獲取月
$day=format_datetime($newstime,"d");//單獨獲取日
$listtemp='
'.$day.'
'.$month.'
'.$year.'年
[!--title--]
[!--smalltext--]';總結
以上是生活随笔為你收集整理的列表页时间日期标签靠显示html,帝国CMS列表页面list.var分别调用年月日,显示个性时间日期...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: layer 同步调用_关于Layer组件
- 下一篇: xmlhttprequest 跨域_跨域