如何給phpcms v9增加類似于phpcms 2008中的關(guān)鍵詞表
更新時(shí)間:2013年07月01日 09:28:17 作者:
本篇文章是對(duì)給phpcms v9增加類似于phpcms 2008中的關(guān)鍵詞表的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
最近用phpcms v9二次開發(fā)一個(gè)人站點(diǎn),之前用2008中有個(gè)比較舒服的關(guān)鍵詞全部顯示出來(lái)功能,而v9將關(guān)鍵詞列表功能增加到了搜索中,如果搜索一個(gè)關(guān)鍵詞就會(huì)自動(dòng)產(chǎn)生一個(gè)增加到了search_keyword表中,這一點(diǎn)不是很喜歡v9;站內(nèi)搜索功能,我覺(jué)得一般會(huì)用得比較少,而我們?cè)谠黾游恼碌臅r(shí)候?qū)嶋H上就把關(guān)鍵詞分隔開了,為什么還要多此一舉了,其實(shí)改起來(lái)也比較簡(jiǎn)單
在model文件夾中增加一個(gè)keyword_ext_model.class.php。keyword_model實(shí)際是存在model文件夾中的,不知道為什么沒(méi)有keyword這張表?
所以還是不要在這個(gè)基本上增加,也許將來(lái)這個(gè)model會(huì)用上
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);
class keyword_ext_model extends model {
public $table_name = '';
public function __construct() {
$this->db_config = pc_base::load_config('database');
$this->db_setting = 'default';
$this->table_name = 'keyword_ext';
parent::__construct();
}
}
?>
然后創(chuàng)建一張表
CREATE TABLE `t_v9_keyword_ext` (
`tagid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`tag` char(50) NOT NULL,
`style` char(5) NOT NULL,
`usetimes` smallint(5) unsigned NOT NULL DEFAULT '0',
`lastusetime` int(10) unsigned NOT NULL DEFAULT '0',
`hits` mediumint(8) unsigned NOT NULL DEFAULT '0',
`lasthittime` int(10) unsigned NOT NULL DEFAULT '0',
`listorder` tinyint(3) unsigned NOT NULL DEFAULT '0',
`modelid` smallint(6) DEFAULT '0',
PRIMARY KEY (`tagid`),
UNIQUE KEY `tag` (`tag`),
KEY `usetimes` (`usetimes`,`listorder`),
KEY `hits` (`hits`,`listorder`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
最后一步在phpcms/modules/content/fields/keyword 中增加一個(gè) input.inc.php
function tags($field, $value)
{
if(!$value) return '';
if(strpos($value, ','))
{
$s = ',';
}
else
{
$s = ',';
}
$keywords = isset($s) ? array_unique(array_filter(explode($s, $value))) : array($value);
$keyword_db = pc_base::load_model('keyword_ext_model');
foreach($keywords as $tag)
{
$tag = trim($tag);
$keyword_db->delete(array("tag"=>$tag,"modelid"=>$this->modelid));
$c=$this->db->count("keywords like '%".$tag."%'");
$keyword_db->insert(array("modelid"=>$this->modelid,"tag"=>$tag,"usetimes"=>$c,"lastusetime"=>SYS_TIME),false,true);
}
return implode($s, $keywords);
}
這樣在文章增加關(guān)鍵詞的時(shí)候,會(huì)自動(dòng)增加到keyword_ext中一份,調(diào)用全站tags的時(shí)候直接調(diào)上這個(gè)表就行了。請(qǐng)得先清除全站緩存,否則修改后看不到效果。
在model文件夾中增加一個(gè)keyword_ext_model.class.php。keyword_model實(shí)際是存在model文件夾中的,不知道為什么沒(méi)有keyword這張表?
所以還是不要在這個(gè)基本上增加,也許將來(lái)這個(gè)model會(huì)用上
復(fù)制代碼 代碼如下:
<?php
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_sys_class('model', '', 0);
class keyword_ext_model extends model {
public $table_name = '';
public function __construct() {
$this->db_config = pc_base::load_config('database');
$this->db_setting = 'default';
$this->table_name = 'keyword_ext';
parent::__construct();
}
}
?>
然后創(chuàng)建一張表
復(fù)制代碼 代碼如下:
CREATE TABLE `t_v9_keyword_ext` (
`tagid` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`tag` char(50) NOT NULL,
`style` char(5) NOT NULL,
`usetimes` smallint(5) unsigned NOT NULL DEFAULT '0',
`lastusetime` int(10) unsigned NOT NULL DEFAULT '0',
`hits` mediumint(8) unsigned NOT NULL DEFAULT '0',
`lasthittime` int(10) unsigned NOT NULL DEFAULT '0',
`listorder` tinyint(3) unsigned NOT NULL DEFAULT '0',
`modelid` smallint(6) DEFAULT '0',
PRIMARY KEY (`tagid`),
UNIQUE KEY `tag` (`tag`),
KEY `usetimes` (`usetimes`,`listorder`),
KEY `hits` (`hits`,`listorder`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
最后一步在phpcms/modules/content/fields/keyword 中增加一個(gè) input.inc.php
復(fù)制代碼 代碼如下:
function tags($field, $value)
{
if(!$value) return '';
if(strpos($value, ','))
{
$s = ',';
}
else
{
$s = ',';
}
$keywords = isset($s) ? array_unique(array_filter(explode($s, $value))) : array($value);
$keyword_db = pc_base::load_model('keyword_ext_model');
foreach($keywords as $tag)
{
$tag = trim($tag);
$keyword_db->delete(array("tag"=>$tag,"modelid"=>$this->modelid));
$c=$this->db->count("keywords like '%".$tag."%'");
$keyword_db->insert(array("modelid"=>$this->modelid,"tag"=>$tag,"usetimes"=>$c,"lastusetime"=>SYS_TIME),false,true);
}
return implode($s, $keywords);
}
這樣在文章增加關(guān)鍵詞的時(shí)候,會(huì)自動(dòng)增加到keyword_ext中一份,調(diào)用全站tags的時(shí)候直接調(diào)上這個(gè)表就行了。請(qǐng)得先清除全站緩存,否則修改后看不到效果。
您可能感興趣的文章:
- 使用PHPCMS搭建wap手機(jī)網(wǎng)站
- phpcms模塊開發(fā)之swfupload的使用介紹
- linux服務(wù)器下PHPCMS v9 安全配置詳解
- php筆記之:初探PHPcms模塊開發(fā)介紹
- PHPCMS的使用小結(jié)
- CodeIgniter使用phpcms模板引擎
- phpcms的分類名稱和類別名稱的調(diào)用
- phpcms手機(jī)內(nèi)容頁(yè)面添加上一篇和下一篇
- PHPCMS手機(jī)站偽靜態(tài)設(shè)置詳細(xì)教程
- PHPCMS忘記后臺(tái)密碼的解決辦法
- 解決phpcms更換javascript的幻燈片代碼調(diào)用圖片問(wèn)題
- phpcms中的評(píng)論樣式修改方法
- PHPCMS V9 添加二級(jí)導(dǎo)航的思路詳解
- PHPCMS遭遇會(huì)員投稿審核無(wú)效的解決方法
- Ajax實(shí)現(xiàn)phpcms 點(diǎn)贊功能實(shí)例代碼
- PHPCMS2008廣告模板SQL注入漏洞修復(fù)
- phpcms配置列表頁(yè)以及獲得文章發(fā)布時(shí)間
- phpcms v9禁止提交信息到官網(wǎng)方法詳解
相關(guān)文章
使用NetBeans + Xdebug調(diào)試PHP程序的方法
前些天發(fā)現(xiàn)通過(guò)Notepad++的DBGP插件結(jié)合PHP的xdebug擴(kuò)展可以實(shí)現(xiàn)PHP文件調(diào)試,同時(shí),介紹說(shuō)包含了單步調(diào)試、監(jiān)視變量還有跨文件調(diào)試。2011-04-04php防止sql注入之過(guò)濾分頁(yè)參數(shù)實(shí)例
這篇文章主要介紹了php防止sql注入中過(guò)濾分頁(yè)參數(shù)的方法,實(shí)例展示了針對(duì)分頁(yè)參數(shù)的數(shù)值判斷問(wèn)題,是非常具有實(shí)用價(jià)值的技巧,需要的朋友可以參考下2014-11-11新安裝的MySQL數(shù)據(jù)庫(kù)需要注意的安全知識(shí)
在你自己安裝了一個(gè)新的MySQL服務(wù)器后,你需要為MySQL的root用戶指定一個(gè)目錄(缺省無(wú)口令),否則如果你忘記這點(diǎn),你將你的MySQL處于極不安全的狀態(tài)(至少在一段時(shí)間內(nèi))。2008-07-07php鏈?zhǔn)讲僮鞯膶?shí)現(xiàn)方式分析
這篇文章主要介紹了php鏈?zhǔn)讲僮鞯膶?shí)現(xiàn)方式,結(jié)合實(shí)例形式對(duì)比分析了常規(guī)調(diào)用與鏈?zhǔn)秸{(diào)用操作的相關(guān)實(shí)現(xiàn)技巧與操作注意事項(xiàng),需要的朋友可以參考下2019-08-08MySQL的FIND_IN_SET函數(shù)使用方法分享
有個(gè)文章表里面有個(gè)type字段,他存儲(chǔ)的是文章類型,有 1頭條,2推薦,3熱點(diǎn),4圖文 …..11,12,13等等2012-03-03php+xml編程之SimpleXML的應(yīng)用實(shí)例
這篇文章主要介紹了php+xml編程之SimpleXML的應(yīng)用,實(shí)例分析了SimpleXML函數(shù)操作XML文件的方法,需要的朋友可以參考下2015-01-01PHP中break及continue兩個(gè)流程控制指令區(qū)別分析
php中常用的for與foreach循環(huán)中,經(jīng)常遇到條件判斷或中止循環(huán)的情況。而處理方式主要用到break及continue兩個(gè)流程控制指令,現(xiàn)在說(shuō)明主要區(qū)別2011-04-04