首页 > 教程 >

织梦采用关键字栏目调用相关文章方法

2023-03-28教程围观

简介调用相关文章,如果是内容页调用则不包含当前这一篇文章把下面代码放到模板你想显示的位置{dede:field.keywordsrunphp=yes}global$dsql,$id,$aid;$aid=isset($id)?$id:$aid;$keyword='';if(!empty(@me)){$keywords=explode(',',trim(@me));$keyword='';$n=1;for

  

调用相关文章,如果是内容页调用则不包含当前这一篇文章

把下面代码放到模板你想显示的位置

{dede:field.keywords runphp=yes}global $dsql,$id,$aid;$aid = isset($id) ? $id : $aid;$keyword = '';if(!empty(@me)){$keywords = explode(',' , trim(@me));$keyword = '';$n = 1;foreach($keywords as $k){if($n > 3) break;if(trim($k)=='') continue;else $k = addslashes($k);$keyword .= ($keyword=='' ? " CONCAT(arc.keywords,' ',arc. ) LIKE '%$k%' " : " OR CONCAT(arc.keywords,' ',arc. ) LIKE '%$k%' ");$n++;}}if($keyword != ''){$sql = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `archives` arc LEFT JOIN `arctype` tp ON arc.typeid=tp.id where arc.arcrank>-1 AND ($keyword) AND arc.id<>'$aid' ORDER BY arc.id desc limit 0, 10";}$dsql->SetQuery($sql);$dsql->Execute('t');$result = '';while($row = $dsql->GetArray('t')){$arcrow = GetOneArchive($row['id']);$row['arcurl'] = $arcrow['arcurl'];$row['pubdate'] = MyDate('Y-m-d',$row['pubdate']);$row['litpic'] = $row['litpic'] = $row['litpic']=='' ? '/images/defaultpic.gif' : $row['litpic'];$result .= "<li><a href="{$row['arcurl']}"><img src="{$row['litpic']}">{$row[' ']}</a></li>";}@me = $result;{/dede:field.keywords}

 


下载链接:网站源码/小程序源码/网站模板下载

Tags: 织梦 方法 文章 关键字 调用