dedecms让arclist标签也支持currentstyle属性
主要用于解决幻灯片当前样式 要解决2个问题
1.默认 class="active"
2.js的id自增
一、找到:
$channelid = $ctag->GetAtt('channelid');
在下面插入:
$currentstyle = $ctag->GetAtt('currentstyle');
二、找到:
return lib_arclistDone( $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen, $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby, $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid, $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'), $tagid, $pagesize, $isweight );
替换为:
return lib_arclistDone ( $refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen, $ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby, $ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid, $ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'), $ctag->GetAtt('noflag'), $tagid, $pagesize, $isweight, $currentstyle );
三、查找:
function lib_arclistDone( &$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160, $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='', $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0, $noflag='', $tagid='', $pagesize=0, $isweight='N' )
替换为:
function lib_arclistDone( &$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160, $imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='', $innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0, $noflag='', $tagid='', $pagesize=0, $isweight='N', $currentstyle='' )
四、查找:
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
在下面插入:
//对currentstyle 进行设置 if($currentstyle && $row['id']==$arcid){ $currentstyle = str_replace('~typelink~',$row['filename'],$currentstyle); $currentstyle = str_replace('~picname~', $row['picname'],$currentstyle); //$currentstyle = str_replace('自定义调用名', 原标签, $currentstyle); $currentstyle = str_replace('~autoindex1~',$GLOBALS['autoindex'], $currentstyle); $row['currentstyle'] = str_replace('~typename~', $row['title'],$currentstyle); }
保存,即可。
至此已经已经解决第一个问题默认 class="active"。
接下来解决 自增标签的全局变量转化
五、查找
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
在下面插入:
//定义全局变量指 field 底层标签 $row['gautoindex'] = $GLOBALS['autoindex'];
调用方法
{dede:arclist row='4' tpyeid="4" channelid='17' currentstyle='<li data-slide-to="~autoindex1~" class="active" data-target="#myzj"><img src="~picname~">~typename~</li>'} [field:array runphp='yes'] if(@me['currentstyle']){ @me = @me['currentstyle']; }else{ @me ="<li data-target='#myzj' data-slide-to='{@me['gautoindex']}' ><img src='{@me['picname']}'>{@me['title']}</li>"; } [/field:array] {/dede:arclist}