|
我们在制作DEDE的模板的时候经常需要用到调用上一级栏目的栏目名称和栏目链接,网上找了一大堆办法,终于实现这个效果
方法如下:
[url=,GetOne("SELECT reid FROM dede_arctype where id=@me"); $reid = $reid['reid',; $typename = $dsql->GetOne("SELECT typedir FROM dede_arctype where id=$reid"); @me=str_replace('{cmspath}','',$typename['typedir',);{/dede:field.typeid}" >{dede:field.typeid runphp='yes'"} global $dsql ; $reid = $dsql->GetOne("SELECT reid FROM dede_arctype where id=@me"); $reid = $reid['reid',; $typename = $dsql->GetOne("SELECT typename FROM dede_arctype where id=$reid"); @me=$typename['typename',;{/dede:field.typeid}[/url]
其中红色字体为栏目链接调用,蓝色字体为栏目名称调用
当然还有别的调用方式及办法,详见如下
调用当前栏目的名称
{dede:field name="typename"}
调用该顶级频道下所有子栏目,row代表调用5条
{dede:channel type='son' row='5'} [url=,[field:typename/][/url] {/dede:channel}
调用子栏目的当前顶级栏目名称
{dede:channel type='top'}[field:typename/] {/dede:channel}
N级子栏目调用最上级栏目名称
{dede:field name='position' runphp='yes'}$tc="-"; //分隔符
$tw=$GLOBALS['cfg_list_symbol',; //调用位置分隔符
$tf=split($tw,@me); //分解成数组
$ta=1;$tk=trim($tf[$ta,);$tk=substr($tk,0]-2);@me=$tk; //赋值给@me
{/dede:field}
N级子栏目调用上级栏目名称
方法1:
{dede:field name='position' runphp='yes'}$tc="-"; //分隔符
$tw=$GLOBALS['cfg_list_symbol',; //调用位置分隔符
$tf=split($tw,@me); //分解成数组
$ta=(count($tf)-3);$tk=trim($tf[$ta,);@me=$tk; //赋值给@me
{/dede:field}
方法2:
[url=,GetOne("SELECT reid FROM dede_arctype where id=@me"); $reid = $reid['reid',; $typename = $dsql->GetOne("SELECT typedir FROM dede_arctype where id=$reid"); @me=str_replace('{cmspath}','',$typename['typedir',);{/dede:field.typeid} >{dede:field.typeid runphp='yes'"} global $dsql ; $reid = $dsql->GetOne("SELECT reid FROM dede_arctype where id=@me"); $reid = $reid['reid',; $typename = $dsql->GetOne("SELECT typename FROM dede_arctype where id=$reid"); @me=$typename['typename',;{/dede:field.typeid}[/url]
调用指定栏目
{dede:type typeid='栏目id'} [url=,[field:typename/][/url] {/dede:type}
DEDE标题栏:文章标题-2级栏目-1级栏目-网站名”样式显示
{dede:field name='title'/}-{dede:field name='position' runphp='yes'}$tc="-"; //分隔符
$tw=$GLOBALS['cfg_list_symbol',; //调用位置分隔符
@me=html2text(@me); //去除html标签
$tf=split($tw,@me); //分解成数组
for($ta=(count($tf)-2);$ta>=1;$ta--){ //循环赋值给$tk
$tk.=trim($tf[$ta,).$tc;}$tk=substr($tk,0]-1);@me=$tk; //赋值给@me
{/dede:field}-{dede:global name='cfg_webname'/}
下面是调用顶级栏目名称的方法:
方法一:
{dede:field.typeid runphp=’yes’}
$ID = @me;
$sql = “SELECT * FROM `dede_arctype` WHERE id=$ID”;
$query = mysql_query($sql);$row=mysql_fetch_array($query);
$relID = “$row[reid,“;
if($relID == 0) {@me = $row[typename,;}
else{$sql = “SELECT `typename` FROM `dede_arctype` WHERE id=$relID”;
$query = mysql_query($sql);
$row=mysql_fetch_array($query);
@me = $row[typename,;}
{/dede:field.typeid} |
|