列表页调用了标题图片。但是有的文章没有标题图片会默认显示notimg.gif比较难看, 如何在列表内容模板list.var里让代码自动判断有图片的就显示。没有图片的的文章不显示默认的notimg.gif。论坛搜索一天没找到答案。 有知道的大神,麻烦给出详细代码。本人较菜。谢谢! 问题解决了.谢谢各位热心的兄弟。因为太菜了 麻烦了好多人。谢谢46819988群的山羊伯,十分感谢! 正确写法如下:
if(empty($r[titlepic])) { $titlepic=' '; } else { $titlepic='<a href="[!--titleurl--]"><img src="[!--titlepic--]"/></a>'; } //-----------------上面的判断是否有图片------------------- $nsmalltext=$r[smalltext]; $ntext=strip_tags($nsmalltext);//去除内容简介里的HTML标签 $newtext=esub($ntext,100,'...') ;//限制100字
$keyboard=$r[keyboard]; $r_tag=explode(",",$keyboard);
$tempid=1;//这里是搜索模板ID
for($i=0;$i<count($r_tag);$i++) { if($r_tag[$i]) { $tagslink=$public_r[newsurl]."e/tags/?tagname=".$r_tag[$i];//链接 $tagslink=$public_r[newsurl]."e/search/?searchget=1&tbname=$tbname&tempid=$tempid&show=keyboard&keyboard=".$r_tag[$i];//如果链接到搜索页面用此行代码,如果不是请删除 $tags.="<a href='$tagslink' target='_blank'>".$r_tag[$i]."</a> "; } } //----------上面是调取关键字,如果你没有这个需要上面就省略掉----------- $listtemp='<div id="listBox"> <div class="listBoxTop"> <div class="listBoxComment"> <span class="countComments">[!--plnum--]</span> <span class="txtComments"> Comments</span> </div> <div class="listBoxTitle"> <h2><a href="[!--titleurl--]" title="[!--oldtitle--]">[!--title--]</a></h2> <span class="timeAuthor"> 发布于:<small> [!--newstime--] </small> | 发布者:<small>[!--username--] </small> </span> </div> </div> <div class="listBoxCenter">'.$titlepic.' <p class="articleIntro">[!--smalltext--]</p> <p class="readMore"><a href="[!--titleurl--]">+阅读全文</a></p> </div> <div class="listBoxBottom"> <small class="listBoxBottomTag">标签:'.$tags.' </small> </small> <small class="listBoxBottomClick">日志分类:<a target="_blank" href="[!--this.classlink--]">[!--this.classname--]</a>围观群众:[!--onclick--]人 </small> </div> </div>';
希望对和我有同样困扰的朋友有帮助。
|