在不影响程序原来功能的基础下,二次开发让上一篇下一篇标签自由可控地输出链接、标题、缩略图、时间,没有上一篇或者下一篇时不输出任何东西
实现好代码教程
打开 /include/arc.archives.class.php 找到 大概在 735 行左右的
else if($ctag->GetName()=='fieldlist')制
在它的上面加入
else if($ctag->GetName()=='prenextdiy') { $innertext = trim($ctag->GetInnerText()); if($innertext) { $get = $ctag->GetAtt('get'); $diys['diy'] = $this->GetPreNext('diy'); $revalue = ''; $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace('field','[',']'); $dtp2->LoadSource($innertext); foreach($diys as $row) { foreach($dtp2->CTags as $tid=>$ctag2) { if(isset($row[$get][$ctag2->GetName()])) { $dtp2->Assign($tid,$row[$get][$ctag2->GetName()]); } } $revalue .= $dtp2->GetResult(); } if($row[$get]['id']) $this->dtp->Assign($i,$revalue); } }
如图
(此图片来源于网络,如有侵权,请联系删除! )
继续找到,大概在852行左右的
$this->PreNext['pre'] = "上一篇:<a rel="nofollow noopener noreferrer" href='$mlink'>{$preRow['title']}</a> ";
在它的上面加入
$preRow['litpic'] = (empty($preRow['litpic'])) " />(此图片来源于网络,如有侵权,请联系删除! )
继续找到,大概在875行左右的
$this->PreNext['next'] = "下一篇:<a rel="nofollow noopener noreferrer" href='$mlink'>{$nextRow['title']}</a> ";在它的上面加入
$nextRow['litpic'] = (empty($nextRow['litpic'])) ? $GLOBALS['cfg_cmspath'].'/images/defaultpic.gif' : $nextRow['litpic']; $this->PreNext['diy']['next']['id'] = $nextRow['id']; $this->PreNext['diy']['next']['arcurl'] = $mlink; $this->PreNext['diy']['next']['title'] = $nextRow['title']; $this->PreNext['diy']['next']['litpic'] = $nextRow['litpic']; $this->PreNext['diy']['next']['pubdate'] = $nextRow['senddate'];如图
(此图片来源于网络,如有侵权,请联系删除! )
继续找到,大概在 889 行左右的
if($gtype=='pre')在它的上面加入
if($gtype=='diy') { return $this->PreNext['diy']; }如图
(此图片来源于网络,如有侵权,请联系删除! )
内容页模板里上一篇下一篇调用标签写法
上一篇 {dede:prenextdiy get='pre'} <li> <a rel="nofollow noopener noreferrer" href="[field:arcurl/]"><img src="[field:litpic/]" width="50" height="50"></a> <p><a rel="nofollow noopener noreferrer" href="[field:arcurl/]">[field:title/]</a><span>时间:[field:pubdate function="MyDate('Y-m-d',@me)"/]</span></p> </li> {/dede:prenextdiy} 下一篇 {dede:prenextdiy get='next'} <li> <a rel="nofollow noopener noreferrer" href="[field:arcurl/]"><img src="[field:litpic/]" width="50" height="50"></a> <p><a rel="nofollow noopener noreferrer" href="[field:arcurl/]">[field:title/]</a><span>时间:[field:pubdate function="MyDate('Y-m-d',@me)"/]</span></p> </li> {/dede:prenextdiy}注意:标签是自定义的dede:prenextdiy
本文织梦上一篇下一篇自由可控输出链接、标题、缩略图、时间到此结束。人世间的真情就像一张大网,时刻温暖着人的心扉,就如妈妈的爱一样,永无止境。小编再次感谢大家支持!