How to retrieve and display all single page lists in AnQi CMS?

Calendar 👁️ 62

Managing and displaying single pages in Anqi CMS is one of the fundamental functions for website content construction.A single page is usually used to create pages with relatively fixed structures and independent content, such as 'About Us', 'Contact Information', or 'Service Introduction', etc.If you want to display a list of single pages in a specific area of the website, such as the footer navigation or sidebar, AnQi CMS provides a very intuitive and flexible way to achieve this.

Backend management: easily create and configure single pages

Before displaying the single-page list on the front end, you first need to create and manage these single pages in the Anqi CMS backend. You can do this in the backend'sPage ResourcesFind it under thePage ManagementIn here, you can perform a series of operations:

  • Add a new pageCreate a new single-page for your website:
  • Edit page content:Customize the page title, SEO information (such as keywords and descriptions), main content (supports rich text editor), and even specify a unique template for the page.
  • Set a custom URL: Assign a more friendly, SEO-friendly URL alias for the page.
  • Sorting and state managementAdjust the display order of a single page or set it to hidden/show status.

Each single page has its own independent ID, title, content, and link, and this information can be conveniently called when displaying the list on the front end.

UtilizepageListTag to get the list of single-page lists

The Anqi CMS provides a powerful tag system for front-end templates, to retrieve and display the list of all single pages, we need to use one of the core tags -pageListThis tag is specifically used to retrieve all single-page data you create in the background.

pageListThe label usage is very concise and clear. You just need to declare a variable in the template to receive a single-page list, then loop through this variable.forThe basic structure is as follows:

{% pageList pages %}
    <ul>
    {% for item in pages %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
    </ul>
{% endpageList %}

In the code above:

  • {% pageList pages %}Declared a namedpagesThe variable will contain all available single-page data.
  • {% for item in pages %}TraversalpagesEach single-page variable will take the current page data and assign it toitemVariable.
  • {{ item.Link }}Will output the access link to the current single-page.
  • {{ item.Title }}It will display the title of the current single page.

In this way, you can easily build a list containing all single page links and titles.

Control and customize the content of the single page list.

In addition to the basic title and link,pageListthe tags in the loop,itemthe variable also provides rich single-page information, which you can selectively display according to your needs:

  • item.Id: The unique identifier ID of the single page.}
  • item.DescriptionThe brief description of the single page.
  • item.Content: Detailed content of a single page (usually not displayed on the list page, but can be called if needed, remember to use|safeHTML filter).
  • item.Logo: Link to the thumbnail large image of the single page setup.
  • item.Thumb: Link to the thumbnail small image of the single page setup.

Advanced customization: Exclude specific pages.

In some cases, you may want to display all single pages but exclude one or two that are not suitable for the list (such as navigation). You canforAdd a conditional judgment inside the loop to achieve:

{% pageList pages %}
    <nav class="site-footer-nav">
        <h3>网站地图</h3>
        <ul>
        {% for item in pages %}
            {% if item.Id != 5 %} {# 假设ID为5的“隐私政策”页面不显示在主导航中 #}
                <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
            {% endif %}
        {% endfor %}
        </ul>
    </nav>
{% endpageList %}

By{% if item.Id != 5 %}This judgment can flexibly control which single pages appear in the list. Here,5Exclude the actual single-page ID you want to replace.

Consideration in a multi-site environment.

If your Anqi CMS is deployed with multiple sites and you want to get the single page list of a specific site,pageListTags also supportsiteIdparameters, for example{% pageList pages with siteId="2" %}. But for most single-site users, it is usually not necessary to specify this parameter, the system will default to fetching the single-page of the current site.

Comprehensive example: Build a bottom navigation list

Combining the above information, we can create a fully functional bottom single-page navigation example:

<footer class="site-footer">
    <div class="container">
        <nav class="footer-nav">
            <h4>关于我们</h4>
            <ul>
            {% pageList pages %}
                {% for item in pages %}
                    {# 排除特定ID的页面,并确保页面有内容或描述才显示 #}
                    {% if item.Id != 10 and (item.Content or item.Description) %}
                        <li>
                            <a href="{{ item.Link }}" title="{{ item.Description }}">
                                {{ item.Title }}
                            </a>
                        </li>
                    {% endif %}
                {% endfor %}
            {% endpageList %}
            </ul>
        </nav>
        <div class="footer-info">
            {# 这里可以添加其他页脚信息,例如版权信息、联系方式等,使用系统标签获取 #}
            <p>&copy; {% now "2006" %} {% system with name="SiteName" %} - All rights reserved.</p>
        </div>
    </div>
</footer>

This example shows how to obtain a single-page list and use simpleifExclude specific pages while utilizingitem.DescriptionAdd title hints to links to enhance user experience. Combine with other system tags (such as{% now %}and{% system %}) to create a more diverse and rich page structure.

Of Security CMSpageListTags make it easy to call and display single-page content, whether it is used to build a navigation menu, a sitemap, or any other scenario that requires listing independent pages, it can provide an efficient and flexible solution.


Frequently Asked Questions (FAQ)

Q1: If I want to retrieve and display a specific single page content instead of the entire list of single pages, which tag should I use?A1: If you only want to display the detailed content of a specific single page, such as all the information on the "About Us" page, you should usepageDetailThe tag allows you to specify the single page to be retrieved by its ID or URL alias, and directly display its title, content, description, and other detailed information.

Q2: Can a single page have categories? Can I set categories for a single page like articles?A2: The single-page design concept in AnQi CMS is used for independent, unclassified content. If you need to manage content categories, such as blog articles, product displays, etc., it is recommended to useContent ManagementbelowDocument ManagementFeature, and create the corresponding "article model" or "product model" and their categories. The single page itself does not have category attributes.

Q3: I created a single-page in the background, but when using it in the foregroundpageListWhy is the label not displayed after that? What could be the reason?A3: There could be several reasons for this:

1.  **页面状态**:请检查该单页面在后台是否被设置为“隐藏”或处于“草稿”状态。只有发布并显示状态的页面才能被 `pageList` 标签获取。
2.  **模板逻辑**:检查您的 `pageList` 循环内部是否有条件判断(如 `{% if item.Id != X %}`)意外地排除了该页面。
3.  **缓存问题**:尝试清除安企CMS后台的缓存,有时缓存会影响内容的即时更新。

Related articles

How to display the complete content and all fields of a single page?

In Anqi CMS, a single page is the basis for building static content pages such as 'About Us' and 'Contact Information'.Effectively displaying the complete content of these pages and all their fields is crucial for website customization and user experience.The Anqi CMS provides intuitive and powerful template tags, allowing you to easily display single-page data configured in the background on the website front-end. To display the complete content of a single page and all related fields, we mainly use the `pageDetail` core template tag.

2025-11-08

How to retrieve custom fields of a category on the category detail page?

When managing website content in AnQi CMS, we often need to make the category page not just a simple aggregation of document lists, but also able to carry more exclusive information to better guide users or display the characteristics of the category.It is particularly important to add and obtain custom fields for categorization at this time.By using these custom fields, you can make each category page unique, whether it's displaying a specific banner image, contact information, or the unique properties of the category.

2025-11-08

How to implement multi-level category nesting display in Anqi CMS?

The organization of website content is crucial for user experience and information retrieval efficiency.A clear and logical classification system can help visitors quickly find the information they need, and also lay a good foundation for the website's SEO.In Anqi CMS, implementing nested display of multi-level categories is the key to building this efficient content architecture.It is not just to list categories simply, but also to modularize and organize the content through hierarchical relationships, whether it is product display, article archive, or service introduction, it can be presented to users in a more intuitive way.

2025-11-08

How to get all category lists under a specified model in AnQi CMS?

AnQi CMS with its flexible content model design makes content management efficient and elastic.Whether it is an enterprise official website, a marketing website, or a personal blog, there may be a need to display the corresponding category list according to different content models (such as articles, products, or custom models).Understanding how to accurately retrieve these categories in the template is a key step in fully utilizing the powerful functions of AnQi CMS.In AnQi CMS, the content model is the foundation of organizing content.

2025-11-08

How to display the document list under the specified Tag label and implement pagination?

In AnQi CMS, the Tag (tag) function is an important tool for organizing and associating content, enhancing user experience and website SEO performance.When your website content becomes richer, how to effectively display the document list under a specified Tag and provide clear pagination navigation is crucial for the discoverability of content and the continuous browsing of users.This article will give you a detailed explanation of how to easily implement this feature by using several key template tags in AnqiCMS.

2025-11-08

How to get and display detailed information of a single Tag label (Title, Description, Logo)?

In AnQi CMS, tags (Tag) are an important way to organize and associate content.Sometimes, we need not only list the tags but also hope to display detailed information about a single tag on an independent page or in a specific area, such as its title, description, and even a representative logo.The AnQi CMS provides a concise and efficient method to meet this requirement. ### Understanding Tag Information Source In the Anqi CMS backend, you can configure the details for each tag.

2025-11-08

How to display the website name, Logo, filing number, and copyright information in Anqi CMS?

When operating a website, the website name, logo, filing number, and copyright information are core elements that constitute the brand image, establish user trust, and meet legal compliance requirements.For users of AnQiCMS, the system provides an intuitive and flexible way to manage and display this information, making your website not only rich in content but also professional and perfect in detail. ### One, centralized management: Configure these key information in the background One of the design philosophies of AnQi CMS is to make website management simple and efficient.

2025-11-08

How to retrieve and display the contact information, phone number, address, and email of the website?

In website operation, a clear and easily searchable contact method is a key factor in building user trust and promoting communication conversion.Whether you are seeking a partner for cooperation or a user in need of help, you can quickly find you through the contact information provided on the website.AnQiCMS provides flexible and convenient functions for managing and displaying contact information, allowing you to easily obtain and display various contact information such as contacts, phone numbers, addresses, and email addresses.

2025-11-08