织梦判断栏目ID问题
织梦怎么判断栏目ID我想导航条每个栏目用不同的样式(下面是代码没能实现){dede:channeltype='top'row='9'}<liid="menu-item"[...
织梦怎么判断栏目ID 我想导航条每个栏目用不同的样式(下面是代码没能实现)
{dede:channel type='top' row='9'}
<li id="menu-item" [field:global name="typeid" runphp="yes" function="GetTopid(@me)"] if(@me!="1")@me="class='movies-slug'"; iif(@me!="4")@me="class='music-slug'";[/field:global]>
<a href="[field:typeurl/]">
[field:typename/]
</a>
</li>
{/dede:channel}
栏目ID是1的时候用class=movies-slug栏目ID是4的时候用class=music-slug 展开
{dede:channel type='top' row='9'}
<li id="menu-item" [field:global name="typeid" runphp="yes" function="GetTopid(@me)"] if(@me!="1")@me="class='movies-slug'"; iif(@me!="4")@me="class='music-slug'";[/field:global]>
<a href="[field:typeurl/]">
[field:typename/]
</a>
</li>
{/dede:channel}
栏目ID是1的时候用class=movies-slug栏目ID是4的时候用class=music-slug 展开
2个回答
展开全部
#@__arctype 表里增加一个 classid 字段
可以直接在后台执行SQL
alter table dede_arctype add column classid VARCHAR(50);
dede/catalog_add.php
搜索
,`smalltypes`
替换为
,`smalltypes`,`classid`
搜索
'0','','','0','0','0','','')";
替换为
'0','','','0','0','0','','','$classid')"
dede/catalog_edit.php 搜索
typename='$typename',
第一个下边增加
classid='$classid',
/dede/templets/catalog_add.htm
搜索
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
<td class='bline'><input name="typename" type="text" id="typename" size="30" class="iptxt" /></td>
</tr>
在起下边增加
<tr>
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目样式:</font></td>
<td class='bline'><input name="classid" type="text" id="classid" size="30" value="" class="iptxt" /> </td>
</tr>
/dede/templets/catalog_edit.htm
搜索
<tr>
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目名称:</font></td>
<td class='bline'><input name="typename" type="text" id="typename" size="30" value="<?php echo $myrow['typename']?>" class="iptxt" /></td>
</tr>
在其下方增加
<tr>
<td class='bline' height="26" style="padding-left:10px;"><font color='red'>栏目样式:</font></td>
<td class='bline'><input name="classid" type="text" id="classid" size="30" value="<?php echo $myrow['classid']?>" class="iptxt" /></td>
</tr>
/include/taglib/channel.lib.php
搜索
if($type=='top')
{
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='son')
{
if($typeid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='self')
{
if($reid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
替换为
if($type=='top')
{
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,classid
From `#@__arctype` WHERE reid=0 And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='son')
{
if($typeid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,classid
From `#@__arctype` WHERE reid='$typeid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
else if($type=='self')
{
if($reid==0) return '';
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,classid
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
}
搜索
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
替换为
$sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,jjm,boxid
FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
搜索
$linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr);
在其下方增加
$linkOkstr = str_replace("~classid~",$row['classid'],$linkOkstr);
模板中调用
{dede:channel type='top' row='9'}
<li id="menu-item" class="[field:classid/]">
<a href="[field:typeurl/]">[field:typename/]</a>
</li>
{/dede:channel}
直接在后台修改栏目中写上css的名称
例如 栏目1 栏目样式:classa
style
.classa {..........}
算是个二次开发~ 睡觉~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询