dedecms列表中显示文章完整标题的解决办法
作者:
dedecms通过标签arclist输出文章列表的时候,文章的标题会被titlelen属性截取为指定长度的字符串, 但是我们在实际使用的过程中,经常会用到文章标题的完整内容,在dedecms中如何实现呢,方法很多,这里推荐通过小小的修改程序,达到目的。
解决方法:
修改include\inc\inc_fun_SpGetArcList.php文件,修改函数SpGetArcList,找到以下代码:
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['title'] = cn_substr($row['title'],$titlelen);
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
修改为:
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['alltitle'] = $row['title']; //增加文章标题属性支持
$row['title'] = cn_substr($row['title'],$titlelen);
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
代码中增加了
$row['alltitle'] = $row['title'];
重新定义一个数组变量存放标题的内容。
然后你在模板中就可以使用类似[field:alltitle/]这样的标签调用文章完整标题。
例如:
{dede:arclist typeid='0' row='6' titlelen=32 orderby='pubdate'}
<li><a href="[field:filename /]" title="[field:alltitle/]">[field:title/]</a></li>
{/dede:arclist}
That about does it - enjoy!
修改include\inc\inc_fun_SpGetArcList.php文件,修改函数SpGetArcList,找到以下代码:
复制代码 代码如下:
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['title'] = cn_substr($row['title'],$titlelen);
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
修改为:
复制代码 代码如下:
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".ereg_replace("['><]","",$row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['alltitle'] = $row['title']; //增加文章标题属性支持
$row['title'] = cn_substr($row['title'],$titlelen);
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
if($row['color']!="") $row['title'] = "<font color='".$row['color']."'>".$row['title']."</font>";
if($row['iscommend']==5||$row['iscommend']==16) $row['title'] = "<b>".$row['title']."</b>";
$row['alltitle'] = $row['title'];
重新定义一个数组变量存放标题的内容。
然后你在模板中就可以使用类似[field:alltitle/]这样的标签调用文章完整标题。
例如:
复制代码 代码如下:
{dede:arclist typeid='0' row='6' titlelen=32 orderby='pubdate'}
<li><a href="[field:filename /]" title="[field:alltitle/]">[field:title/]</a></li>
{/dede:arclist}
That about does it - enjoy!