如何给phpcms v9增加类似于phpcms 2008中的关键词表
最近用phpcms v9二次开发一个人站点,之前用2008中有个比较舒服的关键词全部显示出来功能,而v9将关键词列表功能增加到了搜索中,如果搜索一个关键词就会自动产生一个增加到了search_keyword表中,这一点不是很喜欢v9;站内搜索功能,我觉得一般会用得比较少,而我们在增加文章的时候实际上就把关键词分隔开了,为什么还要多此一举了,其实改起来也比较简单
在model文件夹中增加一个keyword_ext_model.class.php。keyword_model实际是存在model文件夹中的,不知道为什么没有keyword这张表?
所以还是不要在这个基本上增加,也许将来这个model会用上
复制代码 代码如下:
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();
}
}
?>
然后创建一张表
复制代码 代码如下:
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 中增加一个 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);
}
这样在文章增加关键词的时候,会自动增加到keyword_ext中一份,调用全站tags的时候直接调上这个表就行了。请得先清除全站缓存,否则修改后看不到效果。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to add trusted sites in Google Chrome? Some users cannot browse the web normally because the page prompts that it is not secure when surfing the Internet. At this time, they can add the website as a trusted site, and we can access it normally and surf the Internet smoothly. The editor below will bring you the steps to add a trusted site in Google Chrome. The steps are simple and easy to operate, and even beginners can easily get started. Friends who need it can learn about it together. How to add a trusted site in Google Chrome: 1. Open Google Chrome and click the three dots in the upper right corner. Click [Settings]. Choose privacy settings and security. (As shown in the picture) 2. Click Website Settings at the bottom of the page. (As shown in the picture) 3. Click on the unsafe content at the bottom of the page. (As shown in the picture) 4. Click the Add button to the right of the Allow option. (As shown in the picture) 5. Lose

Simple and easy-to-understand Java Hikvision SDK secondary development guide Introduction: With the development of camera surveillance technology, Hikvision has become one of the world's leading security solution providers. The SDK (software development kit) it provides is Developers provide a wealth of functions and interfaces for secondary development and customized development. This article will introduce how to use Java language for secondary development of Hikvision SDK, and provide some code examples to help readers better understand and apply. 1. Environment preparation First, before carrying out secondary development of Hikvision SDK

Serving 80,000 enterprise users, it has helped users fine-tune 13,000 large models and helped users develop 160,000 large model applications. Since December 2023, the daily API calls of Baidu Smart Cloud Qianfan Large Model Platform have increased by 97% month-on-month. ..From the "pioneer" of the domestic large model platform a year ago to today's large model "super factory", Baidu Intelligent Cloud Qianfan large model platform firmly occupies a leading position in the domestic large model market, but its pace is slow. Didn't stop. On March 21, Baidu Intelligent Cloud held a Qianfan product launch conference in Beijing Shougang Park. Baidu Intelligent Cloud announced during the conference: 1. Joining hands with Beijing Shijingshan District to build the country's first Baidu Intelligent Cloud Qianfan large-scale model industrial innovation base to help Promote the take-off of regional industries; 2. Satisfy the “valency” of enterprises

Overview In order to enable ModelScope users to quickly and conveniently use various models provided by the platform, a set of fully functional Python libraries are provided, which includes the implementation of ModelScope official models, as well as the necessary tools for using these models for inference, finetune and other tasks. Code related to data pre-processing, post-processing, effect evaluation and other functions, while also providing a simple and easy-to-use API and rich usage examples. By calling the library, users can complete tasks such as model reasoning, training, and evaluation by writing just a few lines of code. They can also quickly perform secondary development on this basis to realize their own innovative ideas. The algorithm model currently provided by the library is:

Summary of key elements to improve Java Hikvision SDK secondary development skills: With the rapid development of the Internet of Things, video surveillance systems are increasingly used in the security field. As the most important component of the video surveillance system, Hikvision’s SDK plays an important role in the secondary development process. This article will introduce the basic usage of Hikvision SDK and provide some key elements and code examples to help readers improve their Java Hikvision SDK secondary development skills. 1. Understand the basic overview of Hikvision SDK

PHP CMS is a PHP-based open source content management system for managing website content. Its features include ease of use, powerful functionality, scalability, high security, and free open source. It can save time, improve website quality, enhance collaboration and reduce development costs, and is widely used in various websites such as news websites, blogs, corporate websites, e-commerce websites and community forums.

WordPress secondary development allows developers to customize and extend WordPress functionality, creating additional features, themes, and plugins that meet specific needs. Through secondary development, developers can customize WordPress, extend its core functionality, increase its flexibility, and easily expand its scalability as the website and business grow.

Emerging as the brightest star in the technology field in early 2023, it demonstrates the huge potential of Kai AI technology to transform the economy and society. After more than a year of technological breakthroughs and market verification, entering 2024, the huge value of large models has been recognized by mainstream countries, and mainstream technology companies have made plans. Countries such as the United States and China are in the future of leading the development of the large model industry. Among domestic technology companies, Baidu was the first to release Wenxin's large model and has achieved extraordinary results. At the Create2024 Baidu AI Developer Conference held today, Robin Li, founder, chairman and CEO of Baidu, revealed in his keynote speech that the number of Wenxin Yiyan users exceeded 200 million, and the Wenxin Big Model has become China's leading and most widely used model. Extensive AI base models. At the same time, Robin Li
