Unlock AnQiCMS multi-site data:paginationwith the tag andsiteIdParameter in-depth analysis

As an experienced website operations expert, I know that how to accurately and efficiently call and display data in a multi-site management environment is one of the key factors for operation success.AnQiCMS with its flexible multi-site management capabilities provides us with a strong foundation for content operations.Today, let's delve deeply into a problem that often occurs in a multi-site scenario:paginationHow to pass through the tagsiteIdParameters, cleverly call data from a specific site.

The subtleties of AnQiCMS multi-site management

AnQiCMS was designed from the beginning to consider the management needs of enterprise and content operation teams for multiple sites.It allows us to create and independently manage multiple sites within the same system, whether it's a brand sub-site, regional site, or content special topic site, they can all be centrally scheduled and achieve resource sharing and centralized management.This architecture greatly reduces the redundant workload and improves operational efficiency.

In such a multi-site environment, each site has a unique identity标识 in the system——siteId. ThissiteIdIs the core that distinguishes data, configuration, and logic of different sites. Our goal is how to use this at the template levelsiteIdto control the flow of data.

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

Before discussingsiteIdwithpaginationthe relationship, we must first clarifypaginationThe essence of the label's role. It is not a label directly responsible for retrieving data from the database. On the contrary,paginationThe role of the label isprocessing and presentationthose labels that have already been retrieved by other data (such asarchiveList/categoryList/tagDataListetc) ready pagination information.

In simple terms,paginationThe tag expects a pagination object containing total page number, current page, previous and next page links, etc. (usually named in the template)pagesThen, based on this information, generate the familiar pagination navigation such as '1, 2, 3... Next page'.

siteIdThe real stage of parameters: Data acquisition tag

SincepaginationIt does not directly obtain data, thensiteIdWhere does it play a role? The answer lies in thoseResponsible for obtaining list dataThe label in. Check the AnQiCMS template tag document, and you will find that it is to get the article list ofarchiveListcategory list ofcategoryListtag document list oftagDataListStill, some other tags involved in data list calls all have a common important parameter:siteId.

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

  1. Data source specification:First, througharchiveListThis data acquisition tag, clearly indicates to the system that I need to get data from which site (siteId) and what type of data (such asarchiveList)。
  2. Pagination mode enabled:In these data acquisition tags, by settingtype="page"The parameter tells the system 'I need to paginate these data'. At this time, AnQiCMS will automatically generate an object containing all pagination meta-information (for example,pagesVariable)
  3. Pagination navigation generation:Finally, we will pass this label generated by the data acquisitionpagesTo the pagination objectpaginationtag, paginationSo that user-friendly pagination navigation can be generated based on the information in it

Let's go through a specific code example to understand this process:

Suppose you have a main site(siteId="1") and a sub-site(siteId="2"),You want to display the latest articles of the child site on some 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"Applied toarchiveListLabel, explicitly indicating that AnQiCMS retrieves article data from a site with ID 2. WhenarchiveListAfter execution, it not only fills the article list intoarchivesIn the variable, what is more important is that it also generated the pagination metadata for the corresponding article list and made it accessiblepagesvariable forpaginationLabel usage. In this way, we have successfully achieved cross-site pagination data display.

Practical scenarios and value demonstration

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

  • Cross-site content aggregation:Easily display popular articles, latest products, or specific category content from multiple child sites on the main site, forming a content matrix.
  • Unified template management:Even if all sites share a set of templates, they can also pass throughsiteIdParameters, allowing 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 embodies AnQiCMS's focus on providing powerful features while also emphasizing the clarity and ease of use of the template, allowing content operators to focus more on content creation and strategy rather than intricate technical details.

Conclusion

The multi-site management function of AnQiCMS, 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 withpaginationThe combination of data presentation and label responsibilities allows us to manage and display content with ease in complex multi-site environments, bringing users a smoother and more accurate browsing experience.


Frequently Asked Questions (FAQ)

  1. Q:siteIdCan the parameter be used in all AnQiCMS tags?A: Not all tags support it.siteIdParameter.siteIdMainly applied to tags that need to retrieve specific site lists or details from the database, such asarchiveList/categoryList/pageList/tagList/system/contactlikepaginationsuch pure for the page