`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
中增加一个 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
);
}