English manipulation classification list: AnQiCMScategoryListinoffset,limitPractical use of patterns

As an experienced website operations expert, I know how important flexible data display capabilities are when building and optimizing website content. AnQiCMS provides us with many powerful template tags, among whichcategoryListThe label is the core tool for managing website categories. Today, let's delve deeper into it.categoryListtagslimit参数的一个高级用法——”起始位置,数量”模式,看看它如何帮助我们实现更精细、更动态的内容布局。

灵活驾驭数据流:理解limitParameter's "start position, count" mode

We all know,categoryListTagslimitParameters can be used to control the number of categories we want to get, such aslimit="10"will fetch the first 10 categories. However, AnQiCMS provides a more operational mode on this basis:limit="起始位置,数量".

This pattern allows us to accurately extract the part we want from the classification data stream, just like 'slicing'. Specifically:

  • Starting position (Offset)It refers to the starting point from which you want to retrieve the classified list. Please note that in the AnQiCMS mode,the starting position is based on an index of 1.。For example, if you want to start from the 2nd category, the starting position is2.
  • 数量(Limit)It means starting from the specified starting position and getting a total of how many category data items you want.

For example,limit="3,5"It means that AnQiCMS will find the 3rd category from your category data and then count backward to extract a total of 5 categories (i.e., the 3rd, 4th, 5th, 6th, and 7th categories).This fine control capability provides us with infinite possibilities for creating diverse content displays.

Practical scenario: Make your website content layout more eye-catching

Mastered起始位置,数量Pattern, we can play a huge role in various operating scenarios:

1. Homepage modular layout: Create a personalized content display area

Imagine your website's homepage, it may need a prominent 'Hot Categories' section to display the top 3 categories; followed by a 'Recommended Categories' section below, showcasing the next 5 categories; and further down, a 'Latest Categories' section to display the most recently released categories.

  • Popular Category Areas (first 3):
    
    {% categoryList hotCategories with moduleId="1" parentId="0" limit="3" %}
        {# 渲染前3个热门分类 #}
    {% endcategoryList %}
    
  • Recommended Category Areas (4th to 8th):
    
    {% categoryList featuredCategories with moduleId="1" parentId="0" limit="4,5" %}
        {# 渲染第4到第8个推荐分类 #}
    {% endcategoryList %}
    
    Through this method, you can easily divide the category list into multiple visually independent blocks, each displaying different ranges of categories, thereby enriching the homepage content and making the layout more flexible, avoiding the monotony of a single list.

2. Content pagination and 'Load more' optimization: improve user experience

Although AnQiCMS provides a comprehensivetype="page"CombinepaginationTags implement traditional pagination, but in some scenarios, we may need a more flexible "load more" mechanism, or load specific batches of content on demand without displaying a complete pagination navigation.

  • Load initially (first 10):
    
    {% categoryList initialLoad with moduleId="1" parentId="0" limit="10" %}
        {# 首次加载页面时显示前10个分类 #}
    {% endcategoryList %}
    
  • After clicking 'Load More' (next 10, i.e., 11 to 20):This usually requires dynamic modification with JavaScriptoffsetValue)
    
    {% categoryList nextLoad with moduleId="1" parentId="0" limit="11,10" %}
        {# 再次点击加载更多时,从第11个分类开始显示10个 #}
    {% endcategoryList %}
    
    This pattern makes the "load more" feature logic clearer, allowing precise fetching of the next batch of data from the server based on user actions such as scrolling and clicking, providing a smooth browsing experience.

3. Flexible display of sidebars or widgets: precise control of local content

The sidebars, bottoms, or various widgets of websites often need to display concise categories