Let's share a phpcms V9 two times to develop custom paging functions.
Here's how:
First open the phpcms\libs\functions\global.func.php this file, find the paging function, copy, paste into the default paging function below, renamed, for example, my name is Wz_pages, save.
Open phpcms/libs/classes/template_cache.class.php, find 207 rows of:
$str. = ' $pages = Pages ($ '. $op. ' _total, $page, $pagesize, $urlrule);
In this line, add the following:
$str. = ' $wz _pages = wz_pages ($ '. $op. ' _total, $page, $pagesize, $urlrule);
Save. Finally, if you want to use your custom paging function, then you can use {$WZ _pages} directly in the template, then modify the style and modify it directly:
Phpcms\libs\functions\global.func.php the Wz_pages function in this file can be used without affecting the background.
Subsequent optimizations:
Using the process, found that the use of SQL paging is not working properly, you have to add the following code:
Open phpcms/libs/classes/template_cache.class.php, find 178 rows of:
$str. = ' $r = $get _db->sql_query ("'. $sql. '"); $s = $get _db->fetch_next (); $pages =pages ($s [\ ' count\ '], $page, $pagesize, $urlrule); ';
Add below him:
$str. = ' $r = $get _db->sql_query ("'. $sql. '"); $s = $get _db->fetch_next (); $wz _pages=wz_pages ($s [\ ' count\ '], $page, $pagesize, $urlrule); ';
In this way, the paging of SQL is also normal.
Follow-up optimization again:
A friend mentioned that the member center of the collection List page can not use the above method.
Because the paging function of the Favorites list is set directly in other files, it is not feasible to cache the files by modifying the template, and the following options are available:
See below for specific changes:
Phpcms\libs\classes\model.class.php Line 61st
$this->pages = pages ($this->number, $page, $pagesize, $urlrule, $array, $setpages);
Change the above line to:
$this->pages = wz_pages ($this->number, $page, $pagesize, $urlrule, $array, $setpages);
({$pages} in template does not change to {$WZ _pages})
Above is the first method.
But this way, may also affect the background, this place seems to control a lot of places, can also be modified, or the above file, 61 lines do not modify. Add directly below the 61 line:
$this->wz_pages= wz_pages ($this->number, $page, $pagesize, $urlrule, $array, $setpages);
Go to: phpcms\modules\member\index.php 718 line, put the following line
$pages = $this->favorite_db->pages;
Modified to:
$wz _pages = $this->favorite_db->wz_pages;
{$pages} in the template to be modified to {$WZ _pages}, which is the example of a Favorites list, the others are similar.