POST TIME:2020-04-04 15:38
很多人在用dedecms仿站的時候,會用到在當前欄目頁面,欄目標題使用指定樣式(標題加亮,或者放個背景圖)。這是一個很常用和實用的功能,比如在導航頁面,標識當前在瀏覽哪個欄目。(如圖1)
但是有些時候,我們在調用幾篇文章的時候,需要把當前文章的標題加亮。(如圖2)可是dedecms并沒有這個功能,下面我跟大家分享幾段代碼,來實現這個功能。
需要修改的文件為: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);
}
修改好本文件之后,調用代碼如下:
{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}
代碼中的文章標題,行數和樣式名稱可以根據自己的需求來修改。