POST TIME:2020-04-10 19:00
在需要調用相關專題的地方添加:dede標簽{dede:field.keywords function=’getlikespc(@me)’/}
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=’”.$cfg_basehost.”/special/arc-”.$id.”.html’ >”.$title.”</a>”; } return $toback;//返回文章鏈接 }專題列表樣式可修改$toback的樣式