In AnQi CMS, a single page is a very flexible content form that does not rely on complex classification or model structures. It is often used to publish independent and relatively fixed pages such as 'About Us', 'Contact Information', and 'Service Introduction'.These pages are characterized by independent content, usually requiring only one page to carry their information.When you need to display a list of single pages at specific locations on the website, such as the footer navigation, sidebar, or a special topic page, AnQi CMS provides a specialpageListLabel, making this operation simple and intuitive.

Understand the single page in Anqi CMS

In the Anqi CMS backend management interface, you can create and manage single pages under 'Page Resources' -> 'Page Management'.Each single page can have its own title, content, SEO information, even a custom URL, and an independent template file.This design makes single-page become a powerful tool for building the basic structure of a website and displaying specific independent information.For example, you can create a single page for "Company Profile", set a concise URL alias for it, and specify a dedicated page template to showcase its unique design.

pageListLabel: Get the core of the single page list

You need to retrieve these single-page lists created in the background and display them in the front-end template usingpageListThe tag is used to extract all available single-page data for iteration and display in the template.

UsepageListThe tag syntax is very straightforward:

{% pageList pages %}
    {# 在这里遍历 pages 变量,获取每个单页面的信息 #}
{% endpageList %}

In this code block,pagesIs a variable name that you can customize, which will carry all the data sets of single pages. You need to useforto traverse the set so that you can access specific information of each single page.

Traverse and display single page information

In{% pageList pages %}and{% endpageList %}Between tags, you can use it like other list data processing{% for item in pages %}loop to process each single page one by one.itemA variable represents an independent single-page object in each loop, it contains all the available fields of the single page.

A single-page objectitemIt usually includes the following common fields, you can call them as needed:

  • Id: The unique identifier ID of the single page.}
  • Title: Single page title.
  • LinkThe access link of the single page.
  • DescriptionThe brief description of the single page.
  • ContentThe detailed content of the single page.
  • Logo: The cover image of a single page (if set).
  • Thumb: The thumbnail of a single page (if set).

For example, if you want to list all the titles and links of single pages at the bottom of the website, you can write the template code like this:

<nav class="footer-nav">
    <h3>我们的服务</h3>
    <ul>
        {% pageList pages %}
            {% for item in pages %}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% endfor %}
        {% endpageList %}
    </ul>
</nav>

This code generates an unordered list, where each list item is a single-page title, clicking on which will jump to the corresponding single-page.

Advanced Applications and Limitations

pageListA label's characteristic is that it aims to obtainallAn available single page. This means it does not provide filtering parameters by ID or category directly.If you have specific requirements, you need to exclude certain single-page or only display pages that meet specific conditions, you canforConditional judgment statements are used inside the loop ({% if %})to achieve this.

For example, if you want to exclude the "About Us" page with ID 1, you can modify it as follows:

<nav class="footer-nav">
    <h3>我们的服务</h3>
    <ul>
        {% pageList pages %}
            {% for item in pages %}
                {% if item.Id != 1 %} {# 排除ID为1的单页面 #}
                    <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
                {% endif %}
            {% endfor %}
        {% endpageList %}
    </ul>
</nav>

For users managing multiple sites,pageListTags also supportsiteIdparameters. If you have created multiple sites and want to call the single-page data of a specific site, you cansiteIdto specify. For example:{% pageList pages with siteId="2" %}...{% endpageList %}.

In practice, if the content of a single page contains HTML tags and you want these tags to be parsed by the browser normally rather than as plain text, remember to outputitem.ContentUsed at|safefor example:{{ item.Content|safe }}.

BypageListLabel, you can easily build flexible and diverse single-page navigation and content display modules in Anqi CMS templates, greatly enhancing the organization of website content and user experience.


Frequently Asked Questions (FAQ)

  1. pageListCan the tag filter a single page based on specific conditions (such as category, ID)? pageListThe tag is designed to retrieve the list of all single pages, it does not directly provide parameters for filtering single page IDs or categories. If you need to display specific single pages or exclude certain pages, you can use the tag internally{% if %}Condition judgment for manual selection. For example,{% if item.Id != 1 %}You can exclude the single page with ID 1.

  2. How to add pagination functionality to the single page list? pageListThe tag itself does not provide built-in pagination functionality as it is intended to list all the single pages created. If your website has many single pages and needs pagination, you may consider grouping these 'single page' contents under some 'article model' or 'product model' and then using pagination supported by it.archiveListTags for management and display. Or, you can implement pagination effects through JavaScript on the front end.

  3. pageListandarchiveListWhat is the difference? When should they be used? pageListUsed specifically to retrieve and display the 'single page' content created in the 'Page Resources' -> 'Page Management' section of the Anqi CMS backend, which is typically used for fixed content displays such as 'About Us', 'Contact Information', etc. These pages are relatively few in number and independent in content.archiveListIt is used to retrieve and display the content of articles, products, and other documents created under "Document Management" in the "Content Management" section. These contents are usually numerous and need to be classified under specific content models and categories. Simply put, fixed, independent pages are usedpageListUse dynamic, categorized contentarchiveList.