關于織夢CMS的currentstyle高亮屬性相關的一些教程,織夢模板網在前面文章《織夢CMS調用同級欄目及當前文章顯示高亮》和《讓dedecms中channelartlist支持currentstyle屬性》已經做個比較詳細的介紹,
currentstyle屬性在DedeCMS調用標簽里主要用于實現欄目頁的高亮設置,也就是支持dede:channel標簽,而很多時候,我們在調用欄目的時候,會用到dede:channelartlist來調用頂級欄目,這樣currentstyle屬性就不支持了,需要我們做二次發開。
下面我們就這個做個介紹:
打開 include/taglib/channelartlist.lib.php,找到代碼:
$pv->Fields['typeurl'] = GetOneTypeUrlA($typeids[$i]);
在此行代碼下方增加以下代碼:
if($typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['id'] || $typeids[$i]['id'] == $refObj->TypeLink->TypeInfos['topid'] ){ $pv->Fields['currentstyle'] = $currentstyle ? $currentstyle : 'current'; } else{ pv->Fields['currentstyle'] = ''; }網上找到的一般沒有加 $typeids[$i]['id'] ==$refObj->TypeLink->TypeInfos['topid']
添加這個后才能對二級欄目也起作用,調用方法:
{dede:channelartlist typeid='2' currentstyle='current'} <li class='{dede:field.currentstyle/}'><a href='{dede:field name='typeurl'/}'>{dede:field name='typename'/}</a></li> 。。。 {/dede:channelartlist}如果是當前欄目則 li的class屬性顯示current,否則顯示class='' ,也可以修改currentstyle='這里改為你需要的類名'。
以上就是DedeCMS標簽channelartlist如何支持currentstyle屬性的全部內容,希望對大家的學習和解決疑問有所幫助,也希望大家多多支持武林網。新聞熱點
疑難解答