As an expert deeply familiar with the CMS content operation, I am delighted to delve into it for you.{% tagList %}tagslimitThe clever use of parameters, especially how to implement the advanced feature of 'starting to display from the Nth tag'.This can bring great flexibility to content layout and user experience in actual website operations.
Anqi CMS: Masterful Use{% tagList %}TagslimitParameters, to start displaying from the Nth tag
In the Anqi CMS,{% tagList %}Tags are undoubtedly a necessary tool in our content operation.It can easily help us display various tags of the website, making the relevance between content clear at a glance.But often times, we may not be satisfied with simply listing all the tags, but rather want to have more flexible control over their display methods - for example, starting the display from a specific location or skipping the part of the tags before that.{% tagList %}TagslimitParameter, revealing the advanced technique of 'starting from the Nth tag display'.
limitIn-depth analysis of the parameter: not just quantity, but also the starting point.
You may already be familiar withlimitParameters are used to limit the total number of tags displayed, for examplelimit="10"means only the latest 10 tags are displayed. However, in the case of AnQi CMS,limitThe parameters are not just these; it cleverly introduces the concept of 'offset', allowing us to precisely specify from which tag to start data collection.
This secret is hidden inlimitthe parameter'sN,Mspecial format. Among them:
Nrepresents thewhich tag you want fromStart displaying (note: here)Nis based on an index of 1, meaning counting starts from the first).MThen it represents fromNto display, in total how many tags.
In other words,limit="N,M"The meaning is:)From the overall tag list, find the Nth tag and then display M tags starting from this tag.This provides a very fine way to slice data.
Example of practical application: precise control of label display
To better understand this mechanism, we demonstrate its usage through several common scenarios.
Example one: Display the first 5 tags (explicitly specifying from the first one).
If you want to start from the first label and display a total of 5 labels, you can set it like this. This syntax is consistent withlimit="5", 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 3rd tab and display the next 5 tabs
Assuming you want to skip the first 2 tags and start from the 3rd tag, and display a total of 5 tags, 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, the Anqi CMS will first find the third tag in the tag list, and then start from it, and take out the third, fourth, fifth, sixth, and seventh tags for display in turn.
Example three: Display tags from a specified position by combining specific documents or categories
This one with an offsetlimitParameters, can also be used withitemId(tags of specified documents) orcategoryIdCombining parameters such as (specified category tags) provides more detailed control. For example, to display the tags of an article with ID 100, but only show the 2nd to 4th tags (out of 3), you can write it like this:
Display the tags of an article (ID 100) starting from the second one, displaying 3 tags.
<p>文章关联标签 (部分):
{% for tag in articleTags %}
<a href="{{ tag.Link }}" class="article-tag">{{ tag.Title }}</a>
{% endfor %}
</