织梦如何调用相关专题

打开include/extend.func.php文件

在最下面加入

/*author:格展网络

*function:检索和当前页面关键字相同的专题页面

*time:2011.07.08

*/

function getlikespc($keywords=0)

{

global $cfg_basehost,$dsql;

$key = array();

$key = explode(“,”,$keywords);

$likesql;

$len =count($key);

for($i=0;$i<$len;$i++){

$now = $len-$i;

if($now==1){

$likesql .= “keywords like ‘%”.$key[$i].”%’ “;

}else{

$likesql .= “keywords like ‘%”.$key[$i].”%’ or “;

}

}//关键字分割检索,拼接 查询语句

$getsql = “SELECT * from  idea_archives where idea_archives.channel=’-1′ and $likesql order by  idea_archives.id “;//查询与该文章关键字相同的专题

//echo $getsql;

$toback;

$dsql->Execute(“m”,$getsql);

while($row = $dsql->GetObject(‘m’))

{

$title = $row->title;//专题标题

$id = $row->id;//专题ID

$toback = “<a href=https://www.91084.com/’”.$cfg_basehost.”/special/arc-”.$id.”.html’ >”.$title.”</a>”;

}

return $toback;//返回文章链接

}

前端调用

{dede:field.keywords function=’getlikespc(@me)’/}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsfzwg.html