linhuiming
因上努力,果上随缘

11.10 应用举例 Tags调用

  • LinHuiMing

11.10 应用举例 Tags调用

[e:loop={"select * from [!db.pre!]enewstags order by num DESC limit 30",0,24,0}]<?echo '<li><a href="'.$public_r[newsurl].'e/tags/?tagname='.urlencode($bqr['tagname']).'">'.$bqr['tagname'].'<span class="tag-count"> ('.$bqr['num'].')</span></a></li>';?>[/e:loop]

随机标签

    <div class="whitebg cloud">      <h2 class="side-title">标签云</h2>      <ul>     [showtags]'',20,0,'rand() desc',0,'',' ',1,'&tempid=8','tagid'[/showtags]      </ul>    </div>

列表页调用关键字tag

$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/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 class=""> <h3 class=""> <a href="[!--titleurl--]" target="_blank" title="[!--oldtitle--]">[!--title--]</a></h3> <p title="内容简介">'.$newtext.'...</p> <p class=""><span>标签:</span>'.$tags.'<span class="">[!--newstime--]</span> </p> </div>';

第二种方法代码如下:

$classid=$r[classid]; //获取栏目id$tbname=$class_r[$classid][tbname];//获取数据表$fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_".$tbname."_data_{$r[stb]} where id='$r[id]'");//查询副表下的infotags字段$tag1=''.$fr[infotags].'';$r_tag=explode(",",$tag1);  for($i=0;$i<count($r_tag);$i++)        {             if($r_tag[$i])                {                        $tagslink=$public_r[newsurl]."e/tags/?tagname=".$r_tag[$i];//链接                        $tags.="<a href='$tagslink' target='_blank'>".$r_tag[$i]."</a> ";                }        }if(empty($fr[infotags])){$tags="无";}$listtemp=' <p><a class="" href="[!--titleurl--]" target="_blank">[!--title--]</a></p><p class=""> [!--smalltext--] <a href="[!--titleurl--]">[详细]</a></p><div class="">标签:'.$tags.'<p><span>[!--newstime--]</span><span><script src=[!--news.url--]e/public/ViewClick?classid=[!--classid--]&id=[!--id--]&addclick=1></script>人浏览</span><span>来自互联网</span></p></div>';

TAG id
 

$tagstr='';$tsql=$empire->query("select tagid from {$dbtbpre}enewstagsdata where id='$r[id]' and classid='$r[classid]' ");while($tr=$empire->fetch($tsql)){    $tt=$empire->fetch1("select * from {$dbtbpre}enewstags where tagid=".$tr['tagid']." limit 1");    if(!$tt['tagid']){        continue;    }else{        //tagname的动态 或 伪静态 时的链接,采用以下1行代码        //$tagslink=eReturnRewriteTagsUrl(0,$tt['tagname'],1);        //tagid式的动态链接,采用以下1行代码        $tagslink=$public_r['newsurl'].'e/tags/?tagid='.$tt['tagid'].'&tempid=8';        //$tagslink=user_HtmlTagLink($tt['tagid']);    }    $tagstr.='<a title="'.$tagname.'" target="_blank" href="'.$tagslink.'">'.$tt['tagname'].'</a>';}$listtemp='            <li>              <section><a href="[!--titleurl--]" class="news-zuixin-pic"><img src="[!--titlepic--]"></a>                <h2><a href="[!--titleurl--]">[!--title--]</a></h2>                <p>[!--smalltext--]</p>                <span>'.$tagstr.'</span></section>            </li>';
  • YES
  • NO
更多>>

相关文章