As an expert deeply familiar with the content operation of Anqi CMS, I am delighted to analyze it for you in depth{% tagList %}in the taglimitThe clever use of parameters, especially how to implement the advanced feature of 'starting display from the Nth tag'.This can bring great flexibility to content layout and user experience in actual website operation.


Anqi CMS: Skillful application{% tagList %}label'slimitParameter, to display from the Nth tag onwards

In AnQi CMS,{% tagList %}Tags are undoubtedly an indispensable tool in our content operation.It can easily help us display the various tags of the website, making the association between content clear.But many times, we may not be satisfied with simply listing all the tags, but instead hope to have more flexible control over their display methods - such as starting from a specific location or skipping the earlier part of the tags.Today, let's delve into it{% tagList %}label'slimitParameters, revealing how it implements the advanced technique of 'starting from the Nth tag to display.'

limitIn-depth analysis of the parameter: not just the quantity, but also the starting point

You may already be familiar withlimitParameters are used to limit the total number of displayed tags, for examplelimit="10"means that only the latest 10 tags are displayed. However, the AnQiCMS'slimitThe parameters are not limited to this, it cleverly introduces the concept of "offset" (offset), allowing us to precisely specify from which label to start data extraction.

This secret is hidden inlimitThe parameter'sN,Mthis special format. Among them:

  • Nit represents thewhich label you wantto start displaying (note: hereNBased on an index of 1, which means starting from the first).
  • MRepresents starting fromNStarting, how many tags to display in total."),

In other words,limit="N,M"The meaning is:Find the Nth tag from the overall tag list, then start from this tag and display M tags in order.This provides a very fine way of data slicing for you.

For practical examples: precise control of label display

To better understand this mechanism, we demonstrate its usage through several common scenarios.

Example 1: Display the first 5 tags (explicitly specify starting from the first one)

If you want to start from the first tag and display a total of 5 tags, you can set it like this. This format is the same aslimit="5"The function is consistent, but it makes the starting position clearer.

{# 显示从第1个标签开始的5个标签 #}
{% tagList tags with limit="1,5" %}
    <ul class="tag-list">
        {% for tag in tags %}
            <li><a href="{{ tag.Link }}">{{ tag.Title }}</a></li>
        {% endfor %}
    </ul>
{% endtagList %}

Example two: Start from the third tag and display the next 5 tags.

Suppose you want to skip the first 2 tags, start from the 3rd tag, and display a total of 5 tags, then you can use it like this:

{# 从第3个标签开始,显示接下来的5个标签 #}
{% tagList tags with limit="3,5" %}
    <div class="secondary-tags">
        <h3>更多热门标签</h3>
        {% for tag in tags %}
            <span class="tag-item">{{ tag.Title }}</span>
        {% endfor %}
    </div>
{% endtagList %}

In this example, Anqi CMS will first find the third tag in the tag list, and then start from it, taking out the third, fourth, fifth, sixth, and seventh tags for display in turn.

Example three: Combine a specific document or category to display tags from a specified location

This with an offsetlimitParameter, it can also be combined withitemId(tags of the specified document) orcategoryId(Specify category tags) combined with other parameters to provide more detailed control. For example, to display the tags of an article with ID 100 but only show the 2nd to 4th tags (a total of 3), you can write as follows:

”`twig {# Display the tags of an article (ID 100) starting from the second one, displaying 3 tags #} {% tagList articleTags with itemId=100 limit=“2,3” %}

<p>文章关联标签 (部分):
    {% for tag in articleTags %}
        <a href="{{ tag.Link }}" class="article-tag">{{ tag.Title }}</a>
    {% endfor %}
</