POST TIME:2020-04-04 15:38
很多人在用dedecms仿站的時(shí)候,會(huì)用到在當(dāng)前欄目頁(yè)面,欄目標(biāo)題使用指定樣式(標(biāo)題加亮,或者放個(gè)背景圖)。這是一個(gè)很常用和實(shí)用的功能,比如在導(dǎo)航頁(yè)面,標(biāo)識(shí)當(dāng)前在瀏覽哪個(gè)欄目。(如圖1)
但是有些時(shí)候,我們?cè)谡{(diào)用幾篇文章的時(shí)候,需要把當(dāng)前文章的標(biāo)題加亮。(如圖2)可是dedecms并沒(méi)有這個(gè)功能,下面我跟大家分享幾段代碼,來(lái)實(shí)現(xiàn)這個(gè)功能。
需要修改的文件為:include/taglib/arclist.lib.php
一、在65行插入:$currentstyle = $ctag->GetAtt('currentstyle');
二、在135行的$isweight后面加上:,$currentstyle
三、在170行的$isweight='N'和)之間加上:,$currentstyle=''
四、在519行的下方插入:
if($currentstyle && $row['id']==$arcid){
$currentstyle = str_replace('~typelink~', $row['filename'], $currentstyle);
$row['currentstyle'] = str_replace('~typename~', $row['title'], $currentstyle);
}
修改好本文件之后,調(diào)用代碼如下:
{dede:arclist titlelen='42' row='10' currentstyle="
~typename~
"}
[field:array runphp='yes']
if(@me['currentstyle']){
@me = @me['currentstyle'];
}else{
@me = "
{@me['title']}
";
}
[/field:array]
{/dede:arclist}
代碼中的文章標(biāo)題,行數(shù)和樣式名稱可以根據(jù)自己的需求來(lái)修改。
