dede pagelist option参数如何设置?

99ANYc3cd6
预计阅读时长 23 分钟
位置: 首页 DEDE建站 正文

Of course! The dede:pagelist tag is a very useful and flexible tag in DedeCMS (织梦CMS) for generating a list of pagination links. It's highly customizable through its numerous options.

dede pagelist option
(图片来源网络,侵删)

Here is a comprehensive guide to the dede:pagelist tag, covering its syntax, all available options, and practical examples.


Basic Syntax

The dede:pagelist tag is used within an arclist or list template to display pagination for articles.

{dede:pagelist listitem=''/}

The magic happens in the listitem attribute, which tells DedeCMS which parts of the pagination to display.


The listitem Attribute (The Most Important Option)

The listitem attribute is a comma-separated list of keywords that define which pagination elements to show. You can mix and match them to create the exact pagination style you want.

dede pagelist option
(图片来源网络,侵删)

Here are all the available keywords for listitem:

Keyword Description Example Output
info Shows the current page info (e.g., "1/10"). 1/10
textdata Shows the total number of articles (e.g., "共10条"). 共10条
listsize Shows a dropdown to select the number of items per page. [10条/页]
option Shows a "Go" button next to the listsize dropdown. [Go]
pre Shows the "Previous" page link. <
next Shows the "Next" page link. >
pagelink Shows numbered page links (e.g., 1, 2, 3...). 1 2 3 4 5 ...
index Shows a "Home" link. 首页
end Shows an "End" (Last Page) link. 尾页
preinfo Shows a text description for the "Previous" link. 上一页
nextinfo Shows a text description for the "Next" link. 下一页

Other Important Attributes

Besides listitem, you can use these attributes to further customize the output:

Attribute Description Example
listitem (Required) Comma-separated list of items to display. listitem='info,index,end,pre,next,pagelink'
listsize Sets the number of page links to show in the middle. listsize='5'
listitem (Required) Comma-separated list of items to display. listitem='info,index,end,pre,next,pagelink'
listitem (Required) Comma-separated list of items to display. listitem='info,index,end,pre,next,pagelink'
liststyle Sets the CSS class for the pagination container. liststyle='pagelist'
option (Deprecated/Alternative) Can be used to add the "Go" button. option='1'
type option='1' or option='info' to show the total info. type='info'
type option='1' or option='info' to show the total info. type='info'
type option='1' or option='info' to show the total info. type='info'
type option='1' or option='info' to show the total info. type='info'

Practical Examples

Let's see how to use these options in real-world scenarios.

Example 1: Standard Pagination (Most Common)

This is the classic "Previous 1 2 3 ... Next" style.

dede pagelist option
(图片来源网络,侵删)
{dede:pagelist listitem='index,pre,next,pagelink' listsize='5'/}

Output: [首页] < 1 2 3 4 5 ... > [尾页]

Example 2: Detailed Pagination with Info

This shows the current page, total items, and the full navigation.

{dede:pagelist listitem='info,textdata,index,end,pre,next,pagelink' listsize='5'/}

Output: 1/10 共10条 [首页] < 1 2 3 4 5 ... > [尾页]

Example 3: Minimal Pagination

For a clean, simple look, just Previous and Next links.

{dede:pagelist listitem='pre,next,preinfo,nextinfo'/}

Output: 上一页 < 下一页 >

Example 4: Pagination with Items Per Page Selector

This is useful for user-controlled pagination.

{dede:pagelist listitem='listsize,option'/}

Note: option adds the "Go" button. You might need to enable this in your DedeCMS settings or use listitem='listsize,option'.

Output: [10条/页] [20条/页] [30条/页] [Go]

Example 5: Custom Styling with liststyle

You can assign a CSS class to the pagination wrapper to style it with CSS.

{dede:pagelist listitem='pre,next,pagelink' liststyle='my-pagination'/}

You can then style it in your CSS file:

.my-pagination {
  display: flex;
  justify-content: center;
  list-style: none;
  padding: 0;
}
.my-pagination a,
.my-pagination span {
  padding: 5px 10px;
  margin: 0 5px;
  border: 1px solid #ddd;
  text-decoration: none;
  color: #333;
}
.my-pagination a:hover {
  background-color: #f0f0f0;
}
.my-pagination .thisclass { /* The class for the current page */
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

How to Implement in Your Template

  1. Find Your List Template: Navigate to dede/templets/ and open the list_article.htm file. This is the default template for category listing pages.
  2. Locate the Pagination Tag: Find the existing {dede:pagelist} tag. It usually looks something like this:
    <div class="dede_pages">
        <ul class="pagelist">
            {dede:pagelist listitem='info,index,end,pre,next,pagelink' listsize='5'/}
        </ul>
    </div>
  3. Customize the listitem Attribute: Modify the listitem value to your desired combination of options.
  4. Save and Refresh: Save the list_article.htm file and go to your website's category page. Refresh it to see the changes.

Troubleshooting & Common Issues

  • Pagination Not Showing:
    • Make sure you are on a listing page (a category, archive, or search results page), not a single article page.
    • Ensure the pagesize attribute in your {dede:list} tag is set to a reasonable number (e.g., pagesize='20'). If pagesize is set to a very high number, you might only see one page.
  • "Go" Button Not Working:
    • The option keyword is sometimes tied to DedeCMS settings. If it doesn't work, try using listitem='listsize,option' as shown in the examples. If that still fails, it might be a limitation of your DedeCMS version.
  • Styling is Difficult:
    • Use the liststyle attribute to add a custom CSS class. This gives you full control over the styling without interfering with other default styles. Inspect the generated HTML in your browser's developer tools to see the structure and apply CSS accordingly. The current page link usually has a class like thisclass.
-- 展开阅读全文 --
头像
dede orderby=pubdate按什么排序?
« 上一篇 12-02
织梦cms生成首页html的php文件
下一篇 » 12-02

相关文章

取消
微信二维码
支付宝二维码

目录[+]