可能文章的分栏太多?想隐藏掉一些不必要的分栏?那就往下看吧
先添加个字段:
- alter table pw_cms_column add ifdisplay tinyint(3) not null default '1' after allowoffer;
打开mode/cms/template/admin/column.htm文件
找到:
- <tr class="tr1 vt">
- <td class="td2">投稿</td>
- <td class="td2">
- <input type="radio" name="allowoffer" value="1" $allowoffer_Y> 开启
- <input type="radio" name="allowoffer" value="0" $allowoffer_N> 关闭
- </td>
- </tr>
下方添加:
- <tr class="tr1 vt">
- <td class="td2">前台显示</td>
- <td class="td2">
- <input type="radio" name="ifdisplay" value="1" $ifdisplay_Y> 开启
- <input type="radio" name="ifdisplay" value="0" $ifdisplay_N> 关闭
- </td>
- </tr>
打开mode/cms/admin/column.php
找到:
ifcheck(0, 'allowoffer');
下方添加如下代码:
ifcheck(1, 'ifdisplay');
找到:
S::gp(array('name', 'parentId', 'allowoffer', 'order', 'seotitle', 'seodesc', 'seokeywords'));
替换成:
S::gp(array('name', 'parentId', 'allowoffer', 'ifdisplay', 'order', 'seotitle', 'seodesc', 'seokeywords'));
找到:
$datas = array(array($parentId, $name, (int)$order, $allowoffer, $seotitle, $seodesc, $seokeywords));
替换成:
$datas = array(array($parentId, $name, (int)$order, $allowoffer, $ifdisplay, $seotitle, $seodesc, $seokeywords));
找到:
ifcheck($column['allowoffer'], 'allowoffer');
下方添加代码:
ifcheck($column['ifdisplay'], 'ifdisplay');
找到:
S::gp(array('cid', 'name', 'parentId', 'allowoffer', 'order', 'seotitle', 'seodesc', 'seokeywords'));
替换成:
S::gp(array('cid', 'name', 'parentId', 'allowoffer', 'ifdisplay', 'order', 'seotitle', 'seodesc', 'seokeywords'));
找到:
$data = array($parentId, $name, $order, $allowoffer, $seotitle, $seodesc, $seokeywords);
替换成:
$data = array($parentId, $name, $order, $allowoffer, $ifdisplay, $seotitle, $seodesc, $seokeywords);
打开mode/cms/lib/columnservice.class.php
找到方法:
function updateColumn($cid, $data) {.....}
替换成:
- function updateColumn($cid, $data) {
- $_columnDB = $this->loadColumnDB();
- $data = array('parent_id' => $data[0], '`name`' => $data[1], '`order`' => $data[2], 'allowoffer' => $data[3], 'ifdisplay' => $data[4],
- 'seotitle' => $data[5], 'seodesc' => $data[6], 'seokeywords' => $data[7]);
- return $_columnDB->updateColumn($cid, $data);
- }
打开mode/cms/lib/db/columndb.class.php
找到方法:
function insertColumn($datas) {...}
替换成:
- function insertColumn($datas) {
- $_sql = "INSERT INTO " . $this->_tableName . " (`parent_id`,`name`,`order`,`allowoffer`,`ifdisplay`,`seotitle`,`seodesc`,`seokeywords`) VALUES " . S::sqlMulti($datas, false);
- return $this->_db->update($_sql);
- }
以上就可以在后台设置分栏前台显示是否开启或者关闭.下面在文章首页和阅读页进行显示控制.
打开mode/cms/template/default/list.htm
找到:
foreach($columns as $var){
下方添加代码:
if ($var[ifdisplay] == '0'){continue;}
打开mode/cms/template/default/view.htm
找到:
foreach($columns['sub'] as $var){
下方添加代码:
if ($var[ifdisplay] == '0' && ($var['column_id'] != $articleModule->columnId)){continue;}
修改完成!
下面提供phpwind87(20111111)版本的懒人包!