據CMS資源網研究發現,織夢dedecms默認的采集功能只能采集到keywords,不能生成tags標簽,采集完成后還需要再編輯一下才有。如果沒有設置采集description,采集回來的描述這項就是空的,也需要再編輯一下才能生成description內容。
下面CMS資源網就給大家分析一下如何修復這個BUG:
首先打開/dede/co_export.php文件,在大概第183行的位置找到如下代碼:
else if($itemName == 'litpic') { $litpic = trim($ctag->GetInnerText()); } |
在其下面插入以下代碼:
else if($itemName == 'keywords') { $keywords = trim($ctag->GetInnerText()); } else if($itemName == 'body') { $body = trim($ctag->GetInnerText()); $description = cn_substr(html2text($body),150); $description = str_replace(' ','',$description); $description = addslashes($description); } |
然后再找到如下代碼:
$mainSql = str_replace('@sortrank@', $sortrank, $mainSql); |
在其下面插入下面這句:
$mainSql = str_replace('@description@', $description, $mainSql); |
再找到如下代碼:
$rs = $dsql->ExecuteNoneQuery($mainSql); |
在其下面插入如下代碼:
$tags = InsertTags($keywords, $aid); |
這樣就會在采集的時候,發現原網頁上有keywords,采集并導入數據后,就會自動寫入TAG,如果本來沒有keywords,就留空。description的話不管原網頁有沒有,都按采集回來的正文自動生成純文本,不用擔心夾雜亂碼或者原網頁亂七八糟的內容的。
新聞熱點
疑難解答