How to retrieve the list of all single pages using the `pageList` tag and display it on the front end?

Calendar 👁️ 62

As an experienced person who deeply understands the operation of AnQiCMS, I know the core status of content in website construction.A single page serves as the cornerstone for carrying corporate core information, service introduction, contact information, and other static content. Its effective display is crucial for users to understand the website and the corporate image.This article will elaborate on how to use the built-in features of AnQiCMSpageListLabel, retrieve and flexibly display all single page content on the front end.

MasterpageListLabel, build a clear single page navigation and display.

In AnQiCMS, a single page is an important part of the website structure, commonly used for pages such as 'About Us', 'Contact Information', 'Terms of Service', etc., which do not require frequent updates and have relatively fixed content.The management of these pages is carried out in the "Page Resources" module on the back end.To统一或分类展示这些单页面在前端(如网站的底部导航、侧边栏或专门的“解决方案”列表),AnQiCMS provides a powerful and concise template tag—pageList.

pageListThe primary function of the label is to retrieve all the single-page lists that have been created. AndarchiveListDifferent from other labels,pageListThe design philosophy is to obtain comprehensively, rather than based on complex filtering conditions.This means it will return all the visible single-page data on your backend.If you need to further filter or sort these pages, you need to implement it in the loop logic of the frontend template.

UsepageListThe basic syntax structure of the label is concise and clear:

{% pageList pages %}
    {# 在这里循环展示每个单页面信息 #}
{% endpageList %}

Here, pagesIs a variable name that you can customize, which will carry all the single page object arrays obtained from the background. Through this variable, you can use it in{% pageList %}and{% endpageList %}tags betweenforLoop to traverse and render the detailed information of each single page.

pageListThe tag currently supports an optional parameter.siteId. This parameter is mainly used for multi-site management scenarios. If you have created multiple sites in the AnQiCMS background and need to call the single page data of a specific site, you can usesiteIdSpecify. However, for most single-site operators, this parameter is usually not required, and the system will automatically retrieve the single-page list of the current site.

InforIn the loop, each single page object (usually nameditem) contains a wealth of callable fields that allow you to fully display the various properties of the page:

  • IdThe unique identifier of the single page.
  • TitleThe title of a single page, usually the main name that users see on the page.
  • LinkThe access link of the single page.
  • DescriptionA brief description of a single page, often used for SEO or list summaries.
  • Content: Complete content of a single page, usually containing HTML structure.
  • Logo: Thumbnail large image address of a single page.
  • Thumb: Thumbnail address of a single page.

Front-end display example: from basic list to intelligent filtering

UnderstoodpageListAfter learning the basic usage and available fields, we can start with the actual display on the front-end. Below are some common application scenarios and code examples.

Create a simple single-page list

The most direct application is to list all single pages in the footer or navigation menu of a website. This can be achieved through a simpleforloop:

<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 will iterate over all single pages, create a list item for each page, and display its title and link. This is very effective for quickly building the basic navigation of a website.

Filter and exclude specific single page

In practical applications, you may not want all single pages to be displayed in a specific list, for example, you may have an internal use page, or a page that is only displayed under certain conditions. At this point, you canforuse labels insideifFilter conditions. For example, if you need to exclude IDs for1pages titled 'About Us' and those with titles containing 'Privacy':

<div class="sidebar-links">
    <h3>我们的服务</h3>
    <ul>
        {% pageList pages %}
            {% for item in pages %}
                {# 排除ID为1的页面,并且排除标题包含“隐私”的页面 #}
                {% if item.Id != 1 and "隐私" not in item.Title %}
                    <li>
                        <a href="{{ item.Link }}" title="{{ item.Description }}">
                            {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}"/>{% endif %}
                            <span>{{ item.Title }}</span>
                        </a>
                    </li>
                {% endif %}
            {% endfor %}
        {% endpageList %}
    </ul>
</div>

This example not only demonstrates how to exclude specific pages, but also shows how to combineThumbfield to display thumbnails, and throughDescriptionfield to provide more information.

Advanced display: Custom style and layout

Sometimes, you may need to apply unique styles or layouts to certain single-page applications.forloop.Counterandforloop.RevcounterLoop auxiliary variables are very useful at this time.forloop.CounterIndicates the current loop index (starting from 1),forloop.RevcounterIndicates the index from the end.

<div class="special-pages-section">
    {% pageList pages %}
        {% for item in pages %}
            <div class="page-card {% if forloop.Counter == 1 %}featured{% endif %}">
                <h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                {% if item.Logo %}<img src="{{ item.Logo }}" alt="{{ item.Title }}" class="page-logo"/>{% endif %}
                <p>{{ item.Description|truncatechars:100 }}</p> {# 截取描述文字,保持简洁 #}
                <a href="{{ item.Link }}" class="read-more">了解更多</a>
            </div>
        {% endfor %}
    {% endpageList %}
</div>

In this example, we added the first single-page to the list.featuredclass, so that it can be defined with special display effects through CSS. At the same time,Descriptionfield throughtruncatecharsThe filter was truncated to ensure that the text will not be too long in the card layout.

Considerations for content creation and operation

As a website operations manager, while usingpageListWhen using tags, we also need to pay attention to some details of content creation and operation:

first, Page title and descriptionThe input is crucial in the background.pageListThe label directly retrieves this information and displays it on the front end, which not only affects user experience but is also a key element for search engine optimization (SEO).Ensure each single page has a unique, attractive title and a concise, accurate description.

secondly,The management order of the single page.. AlthoughpageListIt does not directly provide a sorting parameter, but the "Page Management" "Display Order" field in the AnQiCMS background can control the default sorting of the page. This means that the order you adjust in the background will usually also be reflected inpageListThe output, unless you have customized sorting logic in your frontend code.

Finally, distinguishSingle-page and article/productusage.pageListIt is suitable for displaying on static information pages, while for dynamically updated blog posts, news, or product information, it should be usedarchiveListorcategoryListTags that are more professional, because they provide richer filtering, sorting, and pagination functions to adapt to the characteristics of dynamic content.

By reasonable applicationpageListTag and logical control of its matching, you can easily build clear, beautiful and functional single-page display modules on the AnQiCMS front-end, thereby enhancing the information architecture and user experience of the website.


Frequently Asked Questions (FAQ)

1.pageListCan the tag retrieve a single specified ID page? pageListThe tag is designed to retrieve all or filtered single-page lists. It does not directly support retrieving a single single-page by ID. If you need to retrieve and display the details of a specific single-page by ID, you should usepageDetailThe tag allows you to pass throughidortokenThe parameter precisely specifies the single page to be obtained.

2. How to controlpageListThe display order of the single page obtained by the tag? pageListThe tag itself does not provideorderParameters are used to directly control sorting. The default sorting of a single page usually depends on the "display order" set in the "Page Management" of the AnQiCMS backend.The smaller the number, the earlier it is displayed. If you need to implement a more complex sorting on the front-end (such as by title alphabetical order), you need to get thepagesData is stored in a variable and then sorted in the custom logic of JavaScript or a template.

3.pageListandarchiveListWhat are the main differences, and when should they be used? pageList主要用于获取和展示single pageThese pages are usually static, informative content, such as "About Us", "Contact Information", "Terms of Service", etc., and they are updated less frequently, without categories, tags, and complex structures. AndarchiveListUsed to retrieve and displayArticles, productsContent that is dynamic, usually belonging to a specific content model (such as an article model, product model), can have categories, tags, comments, custom fields, and support more rich filtering, sorting, and pagination functions. In short,pageListHandle static fixed content,archiveListHandle dynamic structured content.

Related articles

`pageDetail` tag can call which detailed information of a single page (such as ID, title, content)?

As an experienced enterprise CMS website operation person, I know that efficient content management is crucial for the success of the website.The single page is an important part of the website architecture, carrying core static information such as 'About Us', 'Contact Information', and 'Terms of Service'.The Anqi CMS provides a powerful `pageDetail` tag, allowing operators to flexibly call and display various detailed information on a single page.The `pageDetail` tag is a data call tool designed specifically for single-page content in the Anqi CMS template engine

2025-11-06

What happens if the specified single-page template file does not exist?

In AnQi CMS, the single-page template file plays a crucial role, responsible for defining the layout and style of independent pages such as 'About Us' and 'Contact Information'.Website operators usually specify specific template files for these single pages according to business needs to achieve personalized content display.However, if the specified single-page template file does not exist, it will directly affect the normal access and user experience of the page.

2025-11-06

How to specify an independent template file for a single page?

As a senior CMS website operation personnel in an enterprise, I know that the flexibility of content display is crucial for attracting and retaining users.The AnQi CMS provides powerful template customization capabilities, allowing us to specify independent template files for different page features, thereby achieving personalized content layout and design.This is particularly important for creating unique single-page websites, such as 'About Us', 'Contact Information', or specific event landing pages.Understanding AnQi CMS template mechanism All template files in AnQi CMS are stored uniformly in

2025-11-06

Does the single-page content support Markdown format editing?

As a professional deeply familiar with the operation of Anqi CMS, I am very willing to give you a detailed explanation of the support for Markdown format editing in the single-page content of Anqi CMS.The Anqi CMS is committed to providing users with an efficient and flexible content management solution.In terms of content editing, the system provides a richly featured rich text editor, covering a variety of common editing functions such as title settings, text styles (such as bold, italic, underline, strikethrough), lists, alignment, as well as the insertion of images, videos, tables, and code blocks.

2025-11-06

How to determine if a single page exists in the template and display its content?

As an experienced security CMS website operator, I know that it is crucial to flexibly control the display of content in template development, especially for single-page content such as "About Us" and "Contact Us" that may require dynamic judgment and display.In actual operation, we often need to decide whether to render a block or link based on the existence of the page to ensure the accuracy of the website content and the user experience.Below, I will elaborate on how to determine if a single page exists in the Anqi CMS template and display its content.###

2025-11-06

How to use the lazy loading feature of images in single page content?

As an experienced AnQiCMS website operator, I know the importance of website performance for user experience and SEO.Lazy loading of images is an essential optimization method to improve website loading speed, especially on single-page content that contains a large number of images.AnQiCMS provides good support for lazy loading of images at the content rendering level, allowing us to implement this feature through simple template configuration combined with front-end technology. I will elaborate in detail on how to implement lazy loading of images in the single-page content of AnQiCMS.

2025-11-06

How to obtain the SEO title and description of a single page through template tags?

As an experienced security CMS website operator, I am well aware of the key role that each page plays in search engine optimization, especially the SEO title and description.They are not only the first line of defense to attract users to click, but also an important signal to convey the core content of the page to search engines.AnQi CMS is well-versed in this, providing us with powerful and flexible template tags, allowing us to precisely control the SEO elements of each single page.

2025-11-06

How to correctly call the `Link` single page link in the template?

As an experienced security CMS website operator, I know that correctly calling content links in templates is crucial for website user experience and search engine optimization.The single page is a key part that carries static information such as 'About Us' and 'Contact Information', and the accurate calling of its links is an indispensable part of daily operation. I will elaborate in detail on how to correctly call single-page links in the Anqi CMS template.### Understanding Single Page Links in AnQi CMS In AnQi CMS, a single page (also known as a "page") exists independently of content models such as articles, products, and the like.

2025-11-06