0分类的默认显示在首页.不同的分类id号.会自动显示在相应频道
一,/diy/dayrui/models/Navigator_model.php
100行 及174行
增加 'cateid' => $data['cateid']
二,/diy/dayrui/controllers/admin/Navigator.php
322行及429
增加
'cateids' => $this->select_category($this->category_share_model->get_data(), $data['cateid'], 'name=\'data[cateid]\'', fc_lang('只在首页显示')),
46行 增加
'cateid' => array(
'ismain' => 1,
'fieldname' => 'cateid',
'fieldtype' => 'Text',
'setting' => array(
'option' => array(
'width' => 200,
)
)
),
172行 增加
$str.= "<td>\$cateid</td>";
100行左右增加一行,引入category_share_model模型
$this->load->model('navigator_model');
$this->load->model('category_share_model');
并在里面增加一个函数.用来读取所有分类
public function select_category($data, $id = 0, $str = '', $default = ' -- ', $onlysub = 0, $is_push = 0, $is_first = 0) {
$cache = md5(dr_array2string($data).dr_array2string($id).$str.$default.$onlysub.$is_push.$is_first.$this->member['uid']);
if ($cache_data = $this->get_cache_data($cache)) {
return $cache_data;
}
$tree = array();
$first = 0; // 第一个可用栏目
$string = '<select class=\'form-control\' '.$str.'>';
if ($default) {
$string.= "<option value='0'>$default</option>";
}
if (is_array($data)) {
foreach($data as $t) {
// 外部链接不显示
if ($t['tid'] == 2) {
continue;
}
// 验证权限
if (MODULE_PCATE_POST) {
// 父栏目可发布时的权限
if ($is_push) {
if (IS_MEMBER && !$this->module_rule[$t['id']]['add']) {
// 会员中心用户发布权限
if ($is_push && $t['child']) {
$t['html_disabled'] = 1;
} else {
continue;
}
} elseif (IS_ADMIN && !$this->is_category_auth($t['id'], 'add') && !$this->is_category_auth($t['id'], 'edit')) {
// 后台角色发布和修改权限
if ($is_push && $t['child']) {
$t['html_disabled'] = 1;
} else {
continue;
}
}
} else {
// 是否可选子栏目
$t['html_disabled'] = $onlysub ? 1 : 0;
}
// 选中操作
$t['selected'] = '';
if (is_array($id)) {
$t['selected'] = in_array($t['id'], $id) ? 'selected' : '';
} elseif(is_numeric($id)) {
$t['selected'] = $id == $t['id'] ? 'selected' : '';
}
} else {
// 正常栏目权限
if ($is_push && $t['child'] == 0) {
if (IS_MEMBER && !$this->module_rule[$t['id']]['add']) {
continue;
} elseif (IS_ADMIN && !$this->is_category_auth($t['id'], 'add') && !$this->is_category_auth($t['id'], 'edit')) {
continue;
}
}
// 选中操作
$t['selected'] = '';
if (is_array($id)) {
$t['selected'] = in_array($t['id'], $id) ? 'selected' : '';
} elseif(is_numeric($id)) {
$t['selected'] = $id == $t['id'] ? 'selected' : '';
}
// 是否可选子栏目
$t['html_disabled'] = $onlysub && $t['child'] != 0 ? 1 : 0;
}
// 第一个可用子栏目
if ($first == 0 && $t['child'] == 0) {
$first = $t['id'];
}
unset($t['permission'], $t['setting'], $t['catids'], $t['url']);
$tree[$t['id']] = $t;
}
}
$str = "<option value='\$id' \$selected>\$spacer \$name</option>";
$str2 = "<optgroup label='\$spacer \$name'></optgroup>";
$this->load->library('dtree');
$this->dtree->init($tree);
$string.= $this->dtree->get_tree_category(0, $str, $str2);
$string.= '</select>';
if ($is_first) {
$mark = "value='";
$first2 = (int)substr($string, strpos($string, $mark) + strlen($mark));
$first = $first2 ? $first2 : $first;
}
$data = $is_first ? array($string, $first) : $string;
if ($tree) {
$this->set_cache_data($cache, $data, 7200);
}
return $data;
}
三.数据库增加dr_1_navigator 了cateid字段
四. 后台模板./diy/dayrui/templates/admin/navigator_index.html
<th align="left">{fc_lang('名称')}</th>
增加一列
<th align="center" width="80">{fc_lang('友链栏目')}</th>
另外,增加或编辑友情链接的模板也要修改.增加分类字段框
navigator_add.html
里面增加
<div class="form-group">
<label class="col-md-2 control-label">{fc_lang('所属栏目')}:</label>
<div class="col-md-9">
<label>{$cateids}</label>
</div>
</div>
五./templates/pc/web/lww885/common/index_list.html 及link.html 模板
link.html模板调用修改为
<div class="link w_clearfix">
<p class="link_t">友情链接</p>
<div class="link_a">
{php $catid=($catid=='')?0:$catid;$query='select * from @#1_navigator where type=4 and cateid='.$catid;}
{list action=sql sql='$query' }
<a href="{$t.url}">{$t.name}</a>
{/list}
{$error}
</div>
</div>