Recently used Phpcms V9 two times to develop a person site, before using 2008 has a more comfortable keyword all show out function, and v9 the keyword list function added to the search, if search a keyword will automatically generate an increase to the Search_keyword table, This is not very like V9, the station search function, I think generally will be used relatively little, and we add the article when actually the key words separated, why also superfluous, in fact, change is relatively simple
Add a keyword_ext_model.class.php to the Model folder. Keyword_model actually exists in the Model folder, do not know why not keyword this table?
so do not increase in this basically, maybe in the future this model will use
Copy CodeThe code is as follows:
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 ();
}
}
?>
then create a table
Copy CodeThe code is as follows:
CREATE TABLE ' T_v9_keyword_ext ' (
' TagID ' smallint (5) unsigned not NULL auto_increment,
' Tag ' char (not NULL),
' Style ' char (5) is not NULL,
' Usetimes ' smallint (5) unsigned not NULL DEFAULT ' 0 ',
' Lastusetime ' int (ten) unsigned not NULL DEFAULT ' 0 ',
' Hits ' Mediumint (8) unsigned not NULL DEFAULT ' 0 ',
' Lasthittime ' int (ten) 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;
The last step adds a input.inc.php to the Phpcms/modules/content/fields/keyword
Copy CodeThe code is as follows:
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" and $tag, "modelid" = $this->modelid));
$c = $this->db->count ("keywords like '%". $tag. " %'");
$keyword _db->insert ("ModelID" and "->modelid", "tag" + $tag, "usetimes" + $c, "lastusetime" = >sys_time), false,true);
}
Return implode ($s, $keywords);
}
This time in the article to add keywords, will automatically add to the Keyword_ext in a copy, call the whole station tags directly on the table on the line. Please clear the entire station cache first, or you will not see the effect after the modification.
http://www.bkjia.com/PHPjc/327977.html www.bkjia.com true http://www.bkjia.com/PHPjc/327977.html techarticle recently with Phpcms V9 two times to develop a person site, before using 2008 has a more comfortable keyword all show out function, and v9 will keyword list function added to the search, if search ...