dedecms織夢(mèng)相關(guān)專題的調(diào)用方法 。
在需要調(diào)用相關(guān)專題的地方添加:dede標(biāo)簽{dede:field.keywords function=’getlikespc(@me)’/}
include/extend.func.php 文件中添加:
/*author:織夢(mèng)的魚
*function:檢索和當(dāng)前頁(yè)面關(guān)鍵字相同的專題頁(yè)面
*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 “;
}
}//關(guān)鍵字分割檢索,拼接 查詢語(yǔ)句
$getsql = “SELECT * from idea_archives where idea_archives.channel=’-1′ and $likesql order by idea_archives.id “;//查詢與該文章關(guān)鍵字相同的專題
//echo $getsql;
$toback;
$dsql->Execute(“m”,$getsql);
while($row = $dsql->GetObject(‘m’))
{
$title = $row->title;//專題標(biāo)題
$id = $row->id;//專題ID
$toback = “<a href=’”.$cfg_basehost.”/special/arc-”.$id.”.html’ >”.$title.”</a>”;
}
return $toback;//返回文章鏈接
}
專題列表樣式可修改$toback的樣式