Of course! The limit attribute in DedeCMS's {dede:arclist} tag is one of the most frequently used and important parameters. It controls how many articles are displayed in the list.

Here’s a complete guide covering its syntax, usage, and practical examples.
What is limit?
The limit attribute is used to specify the number of articles you want to retrieve from the database and display. It's essential for creating:
- Homepage news tickers (e.g., "Top 5 News")
- Sidebar article lists (e.g., "Popular Articles")
- Feature article sections
- Any paginated list of articles.
Basic Syntax
The limit attribute is placed inside the {dede:arclist} tag.
{dede:arclist limit='number'}
<li>
<a href="[field:arcurl/]">[field:title/]</a>
<span>[field:pubdate function="MyDate('Y-m-d',@me)"/]</span>
</li>
{/dede:arclist}
How to Use limit
The limit attribute accepts values in two main formats:

A. Simple Number (Display a specific number of articles)
This is the most common use case. You simply provide a number, and DedeCMS will display that many articles, starting from the first one in the query (which is usually the newest article based on the default orderby='pubdate').
Syntax: limit='N'
Nis the number of articles you want to display.
Example 1: Display the 5 newest articles
<h3>Latest News</h3>
<ul>
{dede:arclist limit='5'}
<li>
<a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a>
</li>
{dede:arclist}
</ul>
This will list the 5 most recently published articles.

B. Offset and Number (Skip articles and then display)
This format is very powerful for creating paginated lists or for showing articles from a specific point in the list, not just the beginning.
Syntax: limit='start,N'
start: The number of articles to skip (the offset).N: The number of articles to display after skipping.
Example 2: Skip the first 3 articles and show the next 5
This is perfect for a "Read More" section on a homepage where you've already featured the top 3 articles.
<h3>More News</h3>
<ul>
{dede:arclist limit='3,5'}
<li>
<a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a>
</li>
{dede:arclist}
</ul>
How it works:
- The query runs and finds all matching articles (e.g., 50 total).
- It skips the first 3 articles.
- It then displays the next 5 articles (articles 4, 5, 6, 7, and 8).
Practical Examples
Example 1: Homepage Featured Section (Show 1 article)
Let's create a large, featured article box at the top of the homepage. We'll limit it to just the newest article.
<div class="featured-article">
{dede:arclist limit='1' typeid='1' imgwidth='600' imgheight='400'}
<a href="[field:arcurl/]" title="[field:title/]">
<img src="[field:litpic/]" alt="[field:title/]" />
<h2>[field:title/]</h2>
<p>[field:description function='cn_substr(@me, 100)'/]...</p>
</a>
{dede:arclist}
</div>
typeid='1': Only fetches articles from the category with ID 1.imgwidth&imgheight: Automatically resizes the article's thumbnail.
Example 2: Sidebar "Popular Articles" (Show 10 articles)
In the sidebar, you want to list the 10 most popular articles.
<div class="sidebar-widget">
<h3>Popular Articles</h3>
<ul>
{dede:arclist limit='10' orderby='click'}
<li>
<span class="rank">[field:global name=autoindex/]</span>
<a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a>
</li>
{dede:arclist}
</ul>
</div>
orderby='click': Orders the articles by the number of clicks (views), making them "popular".[field:global name=autoindex/]: Creates a numbered list (1, 2, 3, ...).
Example 3: Pagination Simulation (Articles 6-10)
You have a section titled "News Archive" and you want to show articles 6 through 10.
<h3>News Archive (Page 2)</h3>
<ul>
{dede:arclist limit='5,5'}
<li>
<a href="[field:arcurl/]" title="[field:title/]">[field:title/]</a>
<span>[field:pubdate function="MyDate('Y-m-d',@me)"/]</span>
</li>
{dede:arclist}
</ul>
This skips the first 5 articles (start=5) and then displays the next 5 (N=5).
Important Considerations
-
Interaction with
row: Thelimitattribute generally overrides therowattribute. If you use both,limitwill take precedence. It's best practice to use onlylimitfor controlling the number of items.- Avoid:
{dede:arclist row='8' limit='5'}(This will show 5 items). - Use:
{dede:arclist limit='5'}(This is clear and correct).
- Avoid:
-
Default Order: Remember that articles are ordered by their publication date (
pubdate) by default, with the newest first. If you want a different order (e.g., by clicks, by ID), you must use theorderbyattribute.orderby='click': Most clicked/popular.orderby='id': By article ID (usually newest first).orderby='hot'ororderby='scores': By a popularity score.
-
Performance: Using
limitis very efficient because it tells the database to only retrieve a small number of records, which is much faster than fetching all articles and then limiting them in PHP.
Summary Table
| Goal | limit Attribute |
Example Code |
|---|---|---|
| Display the 3 newest articles. | limit='3' |
{dede:arclist limit='3'} |
| Display the 10 most popular articles. | limit='10' + orderby='click' |
{dede:arclist limit='10' orderby='click'} |
| Skip the first 2 articles, show the next 4. | limit='2,4' |
{dede:arclist limit='2,4'} |
| Show a single featured article. | limit='1' |
{dede:arclist limit='1' imgwidth='500'} |
