Add a keyword_ext_model.class.php to the Model folder. Keyword_model actually exists in the Model folder, do not know why there is no keyword this table?
So do not in this basically increase, perhaps the future model will be used,
The code is as follows |
Copy Code |
<?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 (); } } ?> |
Then create a table
code is as follows |
copy code |
CREATE TABLE ' T_v9_keyword_ext ' ( ' TagID ' smallint (5) unsigned not NULL auto_increment, ' Tag ' char (not NULL), ' Style ' char (5) Not NULL, ' Usetimes ' smallint (5) unsigned not NULL DEFAULT ' 0 ', ' Lastusetime ' int (a) unsigned not NULL DEFAULT ' 0 ', ' Hits ' Mediumint (8) unsigned not NULL DEFAULT ' 0 ', ' Lasthittime ' int (a) 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 final step is to add a input.inc.php to the Phpcms/modules/content/fields/keyword.
The code is as follows |
Copy Code |
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); |
So in the article added keyword, will automatically increase to a keyword_ext, call the whole station tags when directly to the table on the line