Unlock AnQiCMS multi-site data:paginationTags andsiteIdIn-depth analysis of parameters

As an experienced website operation expert, I know that how to accurately and efficiently call and display data in a multi-site management environment is one of the keys to operation success.AnQiCMS with its flexible multi-site management capabilities provides us with a powerful foundation for content operation.paginationHow to pass through tagssiteIdParameters, cleverly call specific site data.

The subtleties of AnQiCMS multi-site management

AnQiCMS was designed from the outset to consider the management needs of enterprises and content operation teams for multiple sites.It allows us to create and independently manage multiple sites within the same system. Whether it is a brand sub-site, regional site, or content special theme site, they can be unified dispatch and realize resource sharing and centralized management.This architecture greatly reduces redundant work and improves operational efficiency.

In such a multi-site environment, each site has a unique identity identifier within the system.siteId. ThissiteIdIs the core to distinguish different site data, configuration and logic. Our goal is how to use thissiteIdto control the data flow.

paginationThe core responsibility of the label: data presentation rather than retrieval

In discussingsiteIdWithpaginationBefore discussing the relationship,paginationThe essential role of the label. It is not a label that is directly responsible for retrieving data from the database. On the contrary,paginationThe role of the label isprocessing and presentingthose labels that have already been retrieved by other data (such asarchiveList/categoryList/tagDataList等)ready pagination information.

In simple terms,paginationThe tag expects a "pagination object" that contains information such as total number of pages, current page, and links to previous and next pages (usually named in templates)pages),then generate the familiar '1, 2, 3… Next page' pagination navigation according to this information.

siteIdThe real stage of parameters: data acquisition tags

SincepaginationIt does not directly obtain data, thensiteIdWhere does it play a role? The answer lies in thoseresponsible for obtaining list dataThe tag of. Check the AnQiCMS template tag documentation, and you will find that, whether it is to get the list of articlesarchiveListCategory listcategoryList, or the tag documentation list.tagDataList, or other tags involving data list calls all have an important parameter:siteId.

This is the exquisite point of AnQiCMS in multi-site data call logic. It adopts a clear hierarchical strategy:

  1. Data source specification:Firstly,archiveListThis data fetches tags, explicitly indicating to the system 'I need to get data from which site (siteId) of what type (such asarchiveList)'.
  2. Pagination mode enabled:In these data acquisition tags, by settingtype="page"Parameters, inform the system that 'I need to paginate these data'. At this time, AnQiCMS will automatically generate an object containing all pagination metadata for this data query (for example,pagesVariable).
  3. Page navigation generation:Finally, we will use this tag generated by data acquisitionpagesPage object passed topaginationtags,paginationIt can generate user-friendly pagination navigation based on the information.

Let us understand this process through a concrete code example:.

Suppose you have a main site (siteId="1") and a sub-site (siteId="2"You want to display the latest articles of a sub-site on a certain page of the main site, and you want these articles to be displayed in a paginated manner.

{# 步骤一:使用 archiveList 标签,通过 siteId="2" 参数明确指定从子站点获取数据 #}
{# 同时,设置 type="page" 启用分页模式,AnQiCMS 将自动生成分页信息到全局可用的 "pages" 变量中 #}
{% archiveList archives with siteId="2" type="page" moduleId="1" limit="10" %}
    <div class="subsite-articles">
        <h3>来自子站点的最新文章</h3>
        <ul>
            {% for item in archives %}
            <li>
                <a href="{{ item.Link }}">{{ item.Title }}</a>
                <span>({{ stampToDate(item.CreatedTime, "2006-01-02") }})</span>
            </li>
            {% endfor %}
        </ul>
        {% empty %}
        <p>子站点目前没有可显示的文章。</p>
    </div>
{% endarchiveList %}

{# 步骤二:使用 pagination 标签处理由 archiveList 生成的分页对象 "pages" #}
<div class="pagination-nav">
    {% pagination pages with show="5" %}
        <ul>
            {# 首页链接 #}
            <li class="{% if pages.FirstPage.IsCurrent %}active{% endif %}">
                <a href="{{ pages.FirstPage.Link }}">{{ pages.FirstPage.Name }}</a>
            </li>
            {# 上一页链接 #}
            {% if pages.PrevPage %}
            <li>
                <a href="{{ pages.PrevPage.Link }}">{{ pages.PrevPage.Name }}</a>
            </li>
            {% endif %}
            {# 中间页码 #}
            {% for pageItem in pages.Pages %}
            <li class="{% if pageItem.IsCurrent %}active{% endif %}">
                <a href="{{ pageItem.Link }}">{{ pageItem.Name }}</a>
            </li>
            {% endfor %}
            {# 下一页链接 #}
            {% if pages.NextPage %}
            <li>
                <a href="{{ pages.NextPage.Link }}">{{ pages.NextPage.Name }}</a>
            </li>
            {% endif %}
            {# 尾页链接 #}
            <li class="{% if pages.LastPage.IsCurrent %}active{% endif %}">
                <a href="{{ pages.LastPage.Link }}">{{ pages.LastPage.Name }}</a>
            </li>
        </ul>
    {% endpagination %}
</div>

In this example,siteId="2"Is applied toarchiveListLabel, explicitly indicates that AnQiCMS retrieves article data from a site with ID 2. WhenarchiveListAfter the execution is complete, it not only fills the article list intoarchivesThe variable also generates the pagination metadata corresponding to the article list and makes it accessiblepagesThe variable providespaginationLabel usage. In this way, we have successfully implemented cross-site pagination data display.

Practical scenarios and value demonstration

UnderstandingsiteIdCollaborating with data acquisition tags, it has brought great convenience and flexibility to our content operation on AnQiCMS:

  • Cross-site content aggregation:Easily display multiple child site's hot articles, latest products, or specific category content on the main site to form a content matrix.
  • Unified template management:Even if all sites share a set of templates, they can still besiteIdParameters allow each site to render content and pagination correctly based on its own data.
  • Data isolation and integration:Ensured the independence of data across different sites, but can also be flexibly called and integrated when needed, meeting complex business requirements.

This design philosophy reflects AnQiCMS's focus on providing powerful features while also emphasizing clarity and ease of use in the template layer, allowing content operators to concentrate more on content creation and strategy rather than cumbersome technical details.

Concluding remarks

AnQiCMS's multi-site management function, combined with its flexible template tag system, unlocks the infinite possibilities of content operation for us. Through understandingsiteIdThe core role of the parameter in the data acquisition tag, and its association withpaginationLabels, when combined with data presentation responsibilities, enable us to manage and display content effortlessly in complex multi-site environments, bringing users a smoother and more accurate browsing experience.


Common Questions and Answers (FAQ)

  1. Q:siteId参数可以在所有AnQiCMS标签中使用吗?A: 并非所有标签都支持siteIdParameter.siteIdMainly used for tags that need to retrieve specific site list or detail data from the database, such asarchiveList/categoryList/pageList/tagList/system/contactetc.paginationsuch as purely for the page