{dede:pagelist}是一个用于生成文章列表分页导航的标签,它通常出现在列表模板(list_article.htm页模板(article_article.htm)中,方便用户在不同页面间跳转。

基本语法和作用
基本语法:
{dede:pagelist listitem='index pre pageno next end' listsize='5'/}
作用:
根据当前列表页的页码,生成分页导航链接,
首页 上一页 1 2 3 4 5 6 下一页 末页
常用参数说明
{dede:pagelist}标签的核心在于其listitem和listsize参数。
listitem - 定义显示哪些分页项
这个参数用于控制分页导航中显示哪些元素,多个元素用半角逗号 隔开。

| 参数值 | 说明 | |
|---|---|---|
index |
首页 | 链接到列表的第一页。 |
pre |
上一页 | 链接到当前页的上一页。 |
pageno |
页码 | 显示所有或部分页码数字。 |
next |
下一页 | 链接到当前页的下一页。 |
end |
末页 | 链接到列表的最后一页。 |
option |
下拉跳转 | 生成一个下拉选择框,可直接跳转到指定页。 |
info |
分页信息 | 显示类似 "共X页,当前第Y页" 的信息。 |
示例:
{dede:pagelist listitem='index,pre,pageno,next,end,info'/}
这会显示一个完整的分页导航:首页 上一页 [页码] 下一页 末页 共X页,当前第Y页
listsize - 定义页码显示数量
当listitem包含pageno时,listsize用于控制显示的页码数量,它表示当前页码左右两侧各显示多少个页码。
- 注意:如果总页数较少,会自动调整,不会显示多余的页码。
示例:

{dede:pagelist listitem='pre,pageno,next' listsize='3'/}
如果当前是第5页,总页数为10页,可能会显示:... 3 4 [5] 6 7 ...
liststyle - 定义分页样式
这个参数用于设置分页导航的CSS类名,方便你自定义样式。
- 默认值:
pagelist - 你可以设置为你自己定义的CSS类名,
liststyle='my-pagination'
示例:
{dede:pagelist listitem='pre,pageno,next' liststyle='my-pagination'/}
然后你可以在CSS文件中定义.my-pagination的样式。
完整的常用组合示例
示例1:简洁分页(只显示上一页、页码、下一页)
这是最常用的一种分页样式,简洁明了。
<div class="dede_pages">
<ul class="pagelist">
{dede:pagelist listitem='pre,pageno,next' listsize='3'/}
</ul>
</div>
示例2:完整分页(包含首页、末页和页码信息)
适用于需要完整导航的场景。
<div class="dede_pages">
<ul class="pagelist">
{dede:pagelist listitem='index,pre,pageno,next,end,info' listsize='5'/}
</ul>
</div>
示例3:带下拉跳转的分页
方便用户快速跳转到指定页。
<div class="dede_pages">
<ul class="pagelist">
{dede:pagelist listitem='index,pre,option,next,end' listsize='5'/}
</ul>
</div>
自定义样式
为了让分页导航看起来更美观,你通常需要配合CSS进行样式设计。
在模板中内嵌CSS(不推荐,仅用于测试)
你可以直接在模板的<head>部分或分页HTML附近写CSS。
<style>
/* 基础样式 */
.pagelist {
display: flex;
list-style: none;
padding: 0;
margin: 20px 0;
justify-content: center;
}
.pagelist li {
margin: 0 5px;
}
.pagelist a, .pagelist span {
display: block;
padding: 5px 10px;
border: 1px solid #ddd;
border-radius: 3px;
text-decoration: none;
color: #333;
}
.pagelist a:hover {
background-color: #f0f0f0;
}
/* 当前页样式 */
.pagelist .thisclass {
background-color: #007bff;
color: #fff;
border-color: #007bff;
}
/* 省略号样式 */
.pagelist .ellipsis {
border: none;
padding: 0 5px;
}
</style>
<div class="dede_pages">
<ul class="pagelist">
{dede:pagelist listitem='index,pre,pageno,next,end' listsize='5'/}
</ul>
</div>
推荐做法:在CSS文件中定义
- 在你的模板文件中,给分页容器一个特定的
class,比如class="my-pagination"。 - 在你主题的CSS文件(
/templets/你的主题名/style/css.css)中定义这个class的样式。
模板HTML:
<div class="my-pagination">
{dede:pagelist listitem='pre,pageno,next' liststyle='my-pagination'/}
</div>
CSS文件 (style.css):
/* 为分页链接和span设置基础样式 */
.my-pagination a, .my-pagination span {
display: inline-block; /* 改为inline-block更适合分页 */
padding: 6px 12px;
margin: 0 5px;
border: 1px solid #ddd;
border-radius: 4px;
text-decoration: none;
color: #555;
font-size: 14px;
transition: all 0.2s;
}
.my-pagination a:hover {
background-color: #f8f9fa;
border-color: #aaa;
}
/* 当前页的样式,织梦会自动给当前页码的span加上class="thisclass" */
.my-pagination .thisclass {
background-color: #007bff;
color: #fff;
border-color: #007bff;
cursor: default; /* 当前页不可点击 */
}
/* 省略号的样式 */
.my-pagination .ellipsis {
border: none;
padding: 6px 5px;
color: #999;
}
常见问题与解决
Q1: 分页样式非常丑,是默认的HTML样式。
A: 这是因为你没有添加自定义CSS,请参考上面的“自定义样式”部分,为你的分页添加CSS样式。
Q2: 页码显示 ... 1 2 [3] 4 5 ...,我想要 1 2 3 4 5。
A: 这是listsize参数的正常行为,当总页数很多时,为了不让页码过长,织梦会自动用省略号隐藏中间的页码,如果你希望始终显示所有页码,可以尝试减小listsize的值,但这会导致页码过长,通常的做法是接受这种省略的显示方式。
Q3: 为什么我的分页不显示?
A:
- 检查标签拼写:确保
{dede:pagelist}拼写正确。 - 检查位置:确保标签放在了正确的列表模板(
list_article.htm页模板(article_article.htm)中。 - 检查后台设置:进入后台 -> 系统 -> 系统基本参数 -> 核心设置,检查“列表每页显示条数”是否设置为一个合理的数值(如20、50等),而不是0或1。
- 检查数据:确保你的列表栏目有足够的文章,能够生成多页,如果只有一页,分页导航通常不会显示。
希望这份详细的解析能帮助你完全掌握织梦的{dede:pagelist}
