Home Backend Development PHP Tutorial Method for secondary development of custom paging functions in PHPCMS V9

Method for secondary development of custom paging functions in PHPCMS V9

Mar 21, 2017 pm 03:28 PM

When you build a website, the paging style may often have to be controlled according to the requirements of the template. At this time, many people will modify the pages() function in the global file phpcms\libs\functions\global.func.php. , so the problem arises: this paging function will also affect the background, that is to say, this paging function is shared by the entire site. The following provides a solution: (This requires modifying the file, remember to back up before modifying)
Open the file phpcms\libs\functions\global.func.php, find the paging function, copy it, paste it below the default paging function, and re- Name it, for example, I named it wz_pages, and save it.
Open phpcms/libs/classes/template_cache.class.php and find line 207:

$str .= '$pages = pages($'.$op.'_total, $page, $pagesize, $urlrule);';
Copy after login

Add below this line:

$str .= '$wz_pages = wz_pages($'.$op.'_total, $page, $pagesize, $urlrule);';
Copy after login

Save. Finally, if you want to use your custom paging function, just use {$wz_pages} directly in the template. If you want to modify the style in the future, modify it directly:
phpcms\libs\functions\global.func.php this The wz_pages function in the file is enough and will not affect the background.
Follow-up optimization:

During use, it was found that SQL paging cannot be used normally, and the following code must be added:


Open phpcms/libs/classes/template_cache.class.php and find line 178:

$str .= '$r = $get_db->sql_query("'.$sql.'");$s = $get_db->fetch_next();$pages=pages($s[\'count\'], $page, $pagesize, $urlrule);';
Copy after login

Add below it:

$str .= '$r = $get_db->sql_query("'.$sql.'");$s = $get_db->fetch_next();$wz_pages=wz_pages($s[\'count\'], $page, $pagesize, $urlrule);';
Copy after login

In this way, SQL paging is also normal.
Another follow-up optimization:
A friend mentioned that the above method cannot be used for the collection list pagination in the member center.
Because the paging function of the collection list is directly set in other files, it is not feasible to modify the template cache file. The modification method is provided below:
See the specific modifications below:
phpcms\libs\classes\model .class.php Line 61

$this->pages = pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
Copy after login

Change the above line to:

$this->pages = wz_pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
Copy after login

({$pages} in the template does not need to be changed For {$wz_pages})
The above is the first method.



But in this case, the background may also be affected. This place seems to be controlled In many places, you can also modify it in this way. It is the same file as above. Do not modify line 61. Add directly below line 61:

$this->wz_pages= wz_pages($this->number, $page, $pagesize, $urlrule, $array, $setpages);
Copy after login

Then go to: phpcms\modules\member\index.php line 718 and change the following line

$pages = $this->favorite_db->pages;
Copy after login


Modify to:

$wz_pages = $this->favorite_db->wz_pages;
Copy after login

## {$pages} in the template should be modified to {$wz_pages }, this is taking the collection list as an example, and the others are similar.

The above is the content of the method of secondary development of custom paging functions in PHPCMS V9. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related articles:

How to set SEO settings for the title of PHPCMS V9

Detailed explanation of the idea of ​​adding secondary navigation to PHPCMS V9

Solutions to various problems in secondary development and use of phpcms v9

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Simple and easy-to-understand Java Hikvision SDK secondary development guide Simple and easy-to-understand Java Hikvision SDK secondary development guide Sep 06, 2023 pm 02:01 PM

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

Baidu Intelligent Cloud Qianfan large model platform has been upgraded again: 5 large models and 55 new tool components have been released! Baidu Intelligent Cloud Qianfan large model platform has been upgraded again: 5 large models and 55 new tool components have been released! Mar 22, 2024 am 08:10 AM

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

TensorFlow deep learning framework model inference pipeline for portrait cutout inference TensorFlow deep learning framework model inference pipeline for portrait cutout inference Mar 26, 2024 pm 01:00 PM

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:

Key elements to improve secondary development skills of Java Hikvision SDK Key elements to improve secondary development skills of Java Hikvision SDK Sep 06, 2023 pm 01:42 PM

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

How to jump to the details page in phpcms How to jump to the details page in phpcms Jul 27, 2023 pm 05:23 PM

How to jump to the details page in phpcms: 1. Use the header function to generate a jump link; 2. Loop through the content list; 3. Get the title and details page link of the content; 4. Generate a jump link.

What framework is phpcms? What framework is phpcms? Apr 20, 2024 pm 10:51 PM

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.

Everyone can become an AI developer! Robin Li brings three major AI development tools Everyone can become an AI developer! Robin Li brings three major AI development tools Apr 18, 2024 pm 03:40 PM

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

What does WordPress secondary development mean? What does WordPress secondary development mean? Apr 16, 2024 am 12:09 AM

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.

See all articles