How to get and display the list of all single pages of AnQiCMS using the `pageList` tag?

Calendar 👁️ 56

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.

Related articles

How does the `categoryDetail` tag display the specific category details of AnQiCMS, such as the introduction or Banner image?

In Anqi CMS template development, effectively displaying detailed category information is the key to improving website user experience and SEO performance.`categoryDetail` tag is born for this, it allows us to flexibly obtain and present various information of specific categories, from basic introduction text to visually stunning Banner images, it can easily handle.### Core Function Analysis: `categoryDetail` Tag Overview The `categoryDetail` tag is mainly used to obtain detailed data for a single category

2025-11-08

How to retrieve and display the list of AnQiCMS articles or product categories using the `categoryList` tag?

Build a feature-rich, content-packed website in AnQiCMS, categories are an indispensable part of organizing content.Whether it is to display articles, products, services, or build navigation menus, a clear classification structure can greatly enhance the user experience and maintainability of the website.Today, let's delve deeply into a very practical and flexible tag in AnQiCMS——`categoryList`, which can help you easily obtain and display a list of articles or product categories.The `categoryList` tag is a powerful tool in the AnQiCMS template engine

2025-11-08

How does the `breadcrumb` tag display the breadcrumb navigation path of the AnQiCMS page?

In website operation, clear navigation is a key factor in improving user experience and helping search engines understand the structure of the website.This is a direct navigation aid that can clearly show the hierarchical path of the current page, allowing visitors to always know where they are and where they can go.For users who use AnQiCMS to build and manage websites, achieving such navigation is simple and efficient, thanks to its built-in `breadcrumb` tag.###

2025-11-08

How to build and display a multi-level navigation menu using the `navList` tag on the AnQiCMS website?

The website navigation is an important guide for users when they visit the website. It not only helps users find the information they need quickly, but also reflects the clear structure and friendly user experience of the website.In AnQiCMS, building flexible and diverse navigation menus is a relatively simple and efficient task, mainly due to its powerful `navList` tag.Whether it is a simple single-layer menu or a complex two-level dropdown menu, the `navList` tag can provide strong support.### `navList` label

2025-11-08

How does the `pageDetail` tag display the title, content, and thumbnail of a single page in AnQiCMS?

AnQiCMS provides an efficient way to manage independent pages, such as "About Us", "Contact Information", and so on.These pages usually have independent titles, content, and images, which need to be presented accurately in the front-end template.The `pageDetail` tag is the core tool designed by AnQi CMS to achieve this purpose, allowing us to easily extract and display the detailed information of a single page from the background database.Understanding the `pageDetail` tag: The core of single page content display In AnQiCMS

2025-11-08

How to get and display the document list of the specified category and model in AnQiCMS using the `archiveList` tag?

In Anqi CMS, efficiently managing and displaying website content is the key to improving user experience and search engine rankings.In order to achieve this goal, we often need to organize and display document lists according to specific categories or content models.At this time, the `archiveList` tag has become a powerful tool in our hands.It can help us flexibly extract the required content from the database and present it in a variety of ways.

2025-11-08

How to display AnQiCMS articles with the `archiveDetail` tag?

When building rich web pages in AnQiCMS, the `archiveDetail` tag is undoubtedly the core tool for displaying article detail pages.It can flexibly obtain and present all the detailed information of articles or products, helping website operators easily create detail pages that match the brand image and user experience.

2025-11-08

How to customize the display layout of the article detail page in AnQiCMS?

In website operation, the article detail page is like the 'face' of the content, it not only carries the core information, but is also a key touchpoint for users to understand deeply and resonate.A well-designed, logically laid out detail page that highlights the value of the content, can significantly enhance the user's reading experience, effectively convey information, and even promote further interaction or conversion.AnQi CMS understands its importance and therefore provides highly flexible and customizable features, allowing us to easily create exclusive article detail pages with unique styles.

2025-11-08