How to get and loop through all independent pages in AnQiCMS template (such as About Us)?

Calendar 👁️ 53

In AnQi CMS, sometimes we need to list some independent pages in the website's navigation bar, footer, or other specific areas, such as "About Us", "Contact Us", "Privacy Policy", and so on.These pages usually have fixed content and do not belong to a specific category or article model. AnQiCMS refers to them as 'single pages'.Luckyly, AnQiCMS provides a very intuitive and powerful template tag that can easily retrieve and loop out the information of these single pages.

Core tags:pageList

To achieve the output of all single pages in a template in a loop, we need to usepageListTemplate tag. This tag is specifically designed to retrieve all the independent page data created in the background "Page Resources" -> "Page Management".

pageListThe use of tags is very concise, it returns an array containing all the data of single pages (or a list object), you can specify a variable name for this list, and then iterate through the variable in the template to display the detailed information of each single page.

Basic Usage: Retrieve and display all single-page titles and links

The basic usage is to retrieve the title and link of each single page and display them. For example, you may want to list all the independent pages related to company information at the bottom of the website:

{# 使用 pageList 标签获取所有独立页面,并将其存储在名为 'pages' 的变量中 #}
{% pageList pages %}
    <nav class="footer-pages-nav">
        <ul>
        {# 遍历 'pages' 变量中的每一个页面,每次循环将当前页面数据赋值给 'item' #}
        {% for item in pages %}
            <li>
                {# 输出页面的链接和标题 #}
                <a href="{{ item.Link }}">{{ item.Title }}</a>
            </li>
        {% endfor %}
        </ul>
    </nav>
{% endpageList %}

In this code block:

  • {% pageList pages %}Tell AnQiCMS template engine to get all single page data and assign the result to a variable namedpages.
  • {% for item in pages %}This is a standard loop structure, it will iterate over each onepagesEach single page data in the list, each time the loop assigns the current page data toitemVariable.
  • {{ item.Link }}: Access the current page (item) link address.
  • {{ item.Title }}: Access the current page (item) title.

Deep understanding: fields available on the page data

pageListeach tag looped outitemObjects, all contain a series of practical fields, which you can flexibly call according to your own needs. These fields include:

  • IdThe unique identifier ID of a single page.
  • TitleThe title of a single page, usually used for navigation or list display.
  • LinkThe access link of the single page.
  • DescriptionThe description information of a single page, which can be set in the background.
  • Content: Detailed content of a single page, usually containing HTML formatted text.
  • Logo: Cover image address of a single page, can be uploaded on the backend.
  • Thumb: Thumbnail address of a single page, can be uploaded on the backend.

Useful scenarios: Personalized display and filtering.

In addition to simple titles and links, we can also combine other fields to achieve richer display effects.

Display more page information

Assuming you want to display a thumbnail, title, and brief description of an independent page in an area:

{% pageList pages %}
    <div class="all-pages-overview">
    {% for item in pages %}
        <div class="page-card">
            <a href="{{ item.Link }}">
                {# 如果页面有上传 Logo 图片,则显示它 #}
                {% if item.Logo %}
                    <img src="{{ item.Logo }}" alt="{{ item.Title }}" class="page-card-image">
                {% endif %}
                <h3>{{ item.Title }}</h3>
            </a>
            {# 如果页面有描述,则显示它 #}
            {% if item.Description %}
                <p class="page-card-description">{{ item.Description }}</p>
            {% endif %}
            {# 如果需要显示部分内容,确保对 HTML 内容使用 |safe 过滤器 #}
            {# <div class="page-card-content">{{ item.Content|truncatechars:100|safe }}</div> #}
        </div>
    {% endfor %}
    </div>
{% endpageList %}

We used here{% if item.Logo %}and{% if item.Description %}To determine whether these fields exist, rendering should only be performed when they do, to avoid blank pages or errors. Pay special attention to when you want to outputitem.ContentWhen the page content is rendered, since it may contain HTML tags, in order to ensure that the browser parses it correctly rather than displaying the raw code, you need to use|safeFilter, for example{{ item.Content|safe }}.

Exclude specific pages

pageListThe tag will retrieve all single pages. But if you only want to display a part, or want to exclude certain specific single pages (for example, an internal page that is not intended to be displayed in the navigation), you can use it within the loop.ifConditional statements are used for filtering.

{# 假设我们不想在导航中显示 ID 为 5 和 10 的页面,以及标题为“旧版文档”的页面 #}
{% pageList pages %}
    <nav class="main-pages-nav">
        <ul>
        {% for item in pages %}
            {# 使用 if 语句排除指定 ID 或标题的页面 #}
            {% if item.Id != 5 and item.Id != 10 and item.Title != '旧版文档' %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                </li>
            {% endif %}
        {% endfor %}
        </ul>
    </nav>
{% endpageList %}

In this way, you can flexibly control which pages should be displayed on the front end and which should be hidden.

Summary and advanced tips

pageListThe tag is a very practical feature in the AnQiCMS template system, which makes the management and display of independent pages extremely simple.By mastering its basic usage and available data fields, you can easily build a list of pages that meet various needs.

  • Template path:Remember, the default template for a standalone page is usuallypage/detail.html. If you specify a custom template for a standalone page, such as the "About Us" page usespage/about.htmlMake sure the template file exists in your template directory.
  • The difference between standalone pages and articles/categories:An independent page is more suitable for content that has a simple structure, a lower frequency of updates, and does not require complex classification and archiving.For news, blogs, product lists, and other content that requires frequent updates and categorization management, it is recommended to use AnQiCMS's 'Content Model' and 'Document Classification' features.

Make full use of AnQiCMS,pageListLabels can effectively enhance the structure clarity and user experience of your website.


Frequently Asked Questions (FAQ)

  1. Q: Can I only display some independent pages instead of all of them? A:Of course you can.pageListThe label will retrieve all independent pages, you can filter within itsforUsed in loop:{% if ... %}conditional statements based on page ID, title, or other available fields. For example,{% if item.Id != 1 %}You can exclude the page with ID 1.

  2. **Q: The content of the independent pageContentThe field contains HTML tags, and the source code will be displayed directly. What should I do?

Related articles

How to display the main category in the navigation bar and show the latest products under this category in the dropdown menu?

In website operation, a clear and effective navigation system is the key to improving user experience and website professionalism.AnQiCMS (AnQiCMS) with its flexible content management and powerful template engine, can help us easily achieve complex navigation requirements.Today, let's discuss how to display the main categories in the website's navigation bar and also show the latest products under the category in a dropdown menu when the mouse hovers over it.### One, Understand the navigation and content management basics of AnQiCMS One of the core advantages of AnQiCMS lies in its modular content management system

2025-11-08

How to implement a multi-level nested tree structure display in the category list?

When building website categories, we often need to display a clear, hierarchical structure so that users can intuitively understand the ownership of the website content.AnQiCMS provides powerful template tag features, fully supporting the display of multi-level nested tree structures in category lists, helping you easily create a user-friendly navigation system.The core of achieving this effect lies in the clever use of the `categoryList` template tag of Anqi CMS and its built-in hierarchical judgment function.By looping in the template, you can use the parent-child relationship of the category

2025-11-08

How to retrieve and display detailed information of a specified category, including its description, Banner image, and Logo?

In a content management system, categories are not only the form of content organization, but also the core of website structure and user navigation.Flexibly obtain and display detailed information of a specific category, such as its description, unique banner image and logo, which is crucial for creating attractive and informative pages.AnQiCMS (AnQiCMS) provides an intuitive and powerful template tag to meet this need, allowing you to easily achieve this requirement.### Core Function Tag

2025-11-08

How to retrieve and loop through all document lists under a specific Tag (label) in the template?

In AnQi CMS, content organization can not only be achieved through traditional classification methods, but also flexible "Tag" mechanisms provide a wide space for content association and user search.When you want to display all documents under a specific tag in a certain area of the website, such as the sidebar, related recommendation modules, or even a dedicated Tag aggregation page, AnQi CMS provides a powerful and intuitive template tag that makes this process easy.This article will delve into how to use the Anqi CMS template

2025-11-08

How to get the complete content, SEO information, and associated images of a single page?

In daily website operations, independent pages such as "About Us", "Contact Information", etc., play an important role in conveying core information and shaping the brand image.As content operators, we often need to gain a deep understanding of the structure of these pages, including their main content, SEO information, and all associated image resources, in order to carry out fine management, optimization iteration, or flexible page layout.AnQiCMS provides an intuitive and powerful template tag system, making it easy to obtain these page data.

2025-11-08

How to retrieve and loop the list of friend links in the AnQiCMS template?

In website operation, friendship links are an important means to enhance website authority, increase external traffic, and promote cooperative relations.A convenient management and flexible display of友情链接 function is crucial for any content management system.AnQiCMS as an efficient content management system provides an intuitive way to manage and obtain the list of friend links in templates.This article will thoroughly introduce how to obtain and loop through the list of friendship links on AnQiCMS templates, helping you easily realize the interconnection of websites.

2025-11-08

How to retrieve and display the list of Banner carousel images configured on the website homepage?

In Anqi CMS, the Banner slideshow on the homepage is an important element to attract visitors' attention and display core content.Correctly obtain and display these banner images, which can greatly enhance the visual effects and user experience of the website.Anqi CMS provides intuitive functions and flexible template tags, allowing us to easily achieve this goal. ### First Step: Configure Your Banner Carousel in the Backend Before starting to display the Banner on the website frontend, we first need to configure it in the Anqi CMS backend management system. Typically

2025-11-08

How to display a list of articles with pagination and customize the style and number of pagination navigation pages?

Today, with the increasing richness of website content, how to efficiently display a large number of articles while ensuring a smooth browsing experience is a problem that every website operator needs to consider.AnQiCMS (AnQiCMS) provides a powerful and flexible article list pagination feature, which not only helps to optimize the content presentation of the website, but also allows for better integration into the overall website design through custom styles and page number settings, enhancing the user interaction experience.Next, we will delve into how to implement pagination of the article list in Anqi CMS

2025-11-08