search
Homephp教程PHP开发如何对phpcms v9的首页列表进行分页?

如何对phpcms v9的首页数据列表进行分页?我在phpcms论坛上看到很多相关的帖子提到,但都没有解决这个问题。提出这个问题的人,是想把phpcms v9做成博客的样子,但是不是有很多优秀的博客程序吗,PHP的如WordPress,ASP有zblog等,可能是看中phpcms v9的强大功能吧。说真的我也有这个构想,于是我尝试着使用phpcms v9做成博客,然后对首页数据列表进行分页,发现只可以显示数据列表的第一分页,当点击第二分页时页码还是停留在第一页码上,而且数据记录还是第一分页的。说到这里可能很难说得明白了,那么来看一我的调试记录吧。


下面是首页模板数据列表的代码

{pc:content action="lists" catid="6" num="2" order="id DESC" page="$page"}
{loop $data $r}
    <div class="content">
       <h4 id="a-nbsp-href-r-url-nbsp-title-r-title-r-title-a"><a href="{$r[url]}" title="{$r[title]}">{$r[title]}</a></h4>
         <p class="info">分类:ThinkPHP|时间:{date(&#39;Y-m-d H:i:s&#39;,$r[inputtime])}|浏览量:8999</p>
         <p> {$r[description]}</p>
          <div class="bk20 hr"><hr></div>              
     </div>
{/loop}
<div id="pages" class="text-c">{$pages}</div>
{/pc}

更新首页缓存,再看一下效果,首页数据列表分了3页,当点击第2、3的页码时,地址栏显示URL分别是

http://localhost/phpcms/?page=2
http://localhost/phpcms/?page=3

这没有错,但是页码还是停留在第一页码上,且列表显示的还是第一页的数据,如图所示:

如何对phpcms v9的首页列表进行分页?

这就是问题所在了。


在调试过程中最引起我注意的是,点击页码时,在地址栏显示相应的页码数值,如果能够把页码值传进给"page",会有什么变化呢?于是我把上面代码的

"page="$page""改成了"page="$_GET['page']",再次更新首页缓存,点击第二分页,再次看一下效果图:


如何对phpcms v9的首页列表进行分页?


phpcms v9首页列表分页成功了!∩▂∩这意味着phpcms v9也可以当作功能强大的blog程序。




Statement
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 Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools