Phpcms V9 custom paging function, phpcmsv9 custom Paging
When you create a website, you may need to control the paging style according to the template requirements. At this time, many people will modify the global File phpcms \ libs \ functions \ global. func. the pages () function in php has the following problem: this paging function will affect the background, that is, this paging function is shared across the site.
The solution is as follows: (You have to modify the file and remember to back up the file before modification)
Open
Phpcms \ libs \ functions \ global. func. in the php file, find the paging function, copy it, paste it under the default paging function, and rename it. For example, my file is named wz_pages and saved.
Open
Phpcms/libs/classes/template_cache.class.php, find
$ Str. = '$ pages = pages ($'. $ op. '_ total, $ page, $ pagesize, $ urlrule );';
Add
$ Str. = '$ wz_pages = wz_pages ($'. $ op. '_ total, $ page, $ pagesize, $ urlrule );';
Save.
Finally, if you want to use your custom paging function, you can directly use {$ wz_pages} in the template ,,
Modify the style later.
The wz_pages function in the phpcms \ libs \ functions \ global. func. php file does not affect the background.
I only have the ability to express myself. I can't understand it ,,
Subsequent optimization:
When using SQL pagination, you must add the following code:
Open
Phpcms/libs/classes/template_cache.class.php, find
$ 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 SQL page is normal, and hey, you are welcome to make a brick, don't beat, you have to top Ah ~~
Subsequent optimization:
Some friends mentioned that the above method cannot be used in the member center's favorite list page.
Because the paging function of the favorite list is directly set in other files, it is not feasible to modify the template cache file.
The following is a solution:
Specifically
Phpcms \ libs \ classes \ model. class. php 61 rows
$ This-> pages = pages ($ this-> number, $ page, $ pagesize, $ urlrule, $ array, $ setpages );
Modify the above line:
$ This-> pages = wz_pages ($ this-> number, $ page, $ pagesize, $ urlrule, $ array, $ setpages );
(You do not need to change {$ wz_pages} in the template to {$ pages })
The above is the first method.
However, in this case, the background may also be affected. This place seems to be under control of many places.
You can also modify the file in this way. Do not modify the file in 61 lines. Add the following directly in line 61:
$ This-> wz_pages = wz_pages ($ this-> number, $ page, $ pagesize, $ urlrule, $ array, $ setpages );
Go to phpcms \ modules \ member \ index. php row 718
Set $ pages = $ this-> favorite_db-> pages;
To:
$ Wz_pages = $ this-> favorite_db-> wz_pages;
Modify {$ pages} in the template to {$ wz_pages}