效果图:
很奇怪。明明官方做了公告模块,却没有显示的功能.其实也简单,就是在cms的notice的index方法中操作,查表,然后倒序显示就行.
1.Application/Cms/Controller/NoticeController.class.php->index
public function index(){
$notice_list = M('cms_notice')
->order('id DESC')
->select();
$this->assign('notice_list',$notice_list);
$this->display();
}
2.在Application/Cms/View/Notice下新建index.html
<extend name="$_home_public_layout"/>
<block name="main">
<volist name="notice_list" id="notice_list">
<div class="container well">
<h4 >{$notice_list.title}</h4>
<p>{$notice_list.content}</p>
<h5>
<small>发布:{$notice_list.create_time|date="Y-m-d H:m:s",###}
更新:{$notice_list.update_time|date="Y-m-d H:m:s",###}</small>
</h5>
</div>
</volist>
</block>
3.增强功能:可以在后台模块中添加是否显示前台公告按钮