How to get the list of all single-page lists of a website?

Calendar 👁️ 54

As a senior CMS website operation personnel of a security company, I am well aware of the importance of obtaining and managing website content, especially for single pages that carry core information such as "About Us", "Contact Information", or "Terms of Service".In Anqi CMS, the system provides an efficient and flexible way to obtain the list of these single pages, so that we can integrate it into the website navigation, site map, or other places that need to be displayed.

Understand the single-page in Anqi CMS

The single-page feature of AnQi CMS is designed to manage static content that exists independently and does not belong to any article or product category.These pages typically have a fixed structure and specific purposes, such as company introduction, privacy policy, disclaimer, etc.In website operation, we often need to link these single-page links to the header, footer, or sidebar of the website to ensure that users can easily find and access this important information.Understand how to programmatically obtain the list of these pages, which is the basis for meeting these requirements.

UsepageListTag to get the list of single-page lists

Anqi CMS provides a namedpageListThe template tag, specially designed to retrieve all single-page data on a website. This tag is very concise and efficient, requiring no complex parameter configuration to meet most scenarios.

To usepageListLabel, you can write the template code like this:

{% pageList pages %}
    {# 循环输出单页面数据 #}
{% endpageList %}

Here, pagesIs a custom variable name that will carry frompageListThe label gets all the single page data, this variable is an array (or list) object. You can also choose any other meaningful variable name.{% pageList pages %}and{% endpageList %}The tag pair will enclose the logic you want to process for each single page.

Traverse and display single page data

due topagesThe variable is an array containing multiple single page objects, and we need to useforLoop the tag to iterate over it and extract the details of each single page one by one. Inside the loop, each single page object is usually nameditemOf course, you can also customize this variable name.

EachitemObjects contain a series of available fields that can provide key information on a single page, such as:

  • IdThe unique identifier of the single page.
  • TitleThe title of the single page, usually displayed on the website.
  • LinkThe access link of the single page.
  • DescriptionThe brief description of the single page.
  • ContentThe detailed content of the single page.
  • Logo: The main image or large image of a single page.
  • Thumb: The thumbnail of a single page.

You can select and display these fields according to your actual needs. For example, to create a simple single-page navigation list, you can do it like this:

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

This code will generate an unordered list where each list item is a link to a single page, and the link text is the title of the single page.

Filter and customize the display of single pages

In practice, we may not want all single pages to be displayed in the same list.The AnQi CMS template engine provides flexible control structures, allowing us to filter or customize the display of a single page based on specific conditions.

For example, if you want to exclude a specific ID single page (such as the 'About Us' page with ID 1, as it may already be fixed in the main navigation), you canforAdd within the loopifConditional judgment:

<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>

This method allows us to finely control which single pages appear in the list, thereby meeting different design and operational needs.In addition, if you want to display a thumbnail or description on a single page, just refer to the corresponding field within the loop.

Suitable for multi-site environments

AnQi CMS supports multi-site management,pageListThe label also takes this into account. If you have created multiple sites in the background and need to call single-page data from different sites, you can specify thesiteIdparameter.

{% pageList pages with siteId="2" %} {# 获取ID为2的站点的单页面列表 #}
    {% for item in pages %}
    <li>
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    </li>
    {% endfor %}
{% endpageList %}

However, in most single-site operation scenarios, it is usually not necessary to specify manuallysiteIdbecausepageListthe tag will default to retrieving the single-page data of the current site

background management and template association

In the AnQi CMS backend, the single page management is located under the "Page Resources" section in the "Page Management" module. Here, you can create, edit, and delete single pages, and set the title, content, URL alias for each single page, and even specify independent template files (such aspage/detail.htmlorpage/about.html)。These backend settings directly affect the frontendpageListThe data and display effects that the tag can obtain. For example, if you have customized a URL alias for a single page, thenitem.LinkIt will reflect this custom URL.

By making reasonable use ofpageListThe tag and its rich fields allow you to easily build dynamic single-page lists in Anqi CMS, whether for website navigation, information display, or internal management, it provides great convenience and flexibility.


Frequently Asked Questions (FAQ)

1. I want to display all my single pages in the navigation, but I don't want users to see the single page of the "old contact information". What should I do?

You can usepageListLabel after obtaining all single-page list items, within the loop throughifConditional judgment to exclude pages that you do not want to display. For example, if the title of the "Old Contact Information" page is "Old Contact Information", you can write the code like this:

<ul>
{% pageList pages %}
    {% for item in pages %}
    {% if item.Title != "旧版联系方式" %}
    <li>
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    </li>
    {% endif %}
    {% endfor %}
{% endpageList %}
</ul>

Or, if you know the ID of the single page, useitem.Id != [您的页面ID]Excluding it will be more accurate.

2. Where is the default single-page template file of AnQi CMS, and how can I specify a unique template for a specific single page?

The single-page default template of AnQi CMS is usually stored in the theme directory you are currently using.page/detail.htmlFile. If you need to specify a unique template for a single page, you can create a new template file in the template directory, for examplepage/about.htmlThen edit the single page in the background "Page Management", fill in the "Single Page Template" settingsabout.htmlThe system will prioritize the custom template you specify to render the single page.

How to get the single page list of other sites (in multi-site mode)?

If you have enabled the multi-site feature of Anqi CMS and need to get the single page list of non-current sites, you canpageListthe tag withsiteIdParameters. For example, if you want to get a single-page list of site ID 2, you can use the tag like this:{% pageList pages with siteId="2" %}...{% endpageList %}Make sure you know the correct ID of the target site, which is usually visible in the "Multi-site Management" section of the backend.

Related articles

How to retrieve detailed information for a specified category, such as the category name, description, and link?

As an experienced website content expert in AnQiCMS (AnQiCMS) operation, I fully understand the importance of classification information in building website structure and improving user experience.The Anqi CMS, with its intuitive and powerful template tag system, makes it exceptionally easy to obtain and display detailed information about categories.In order to optimize navigation, enrich page content, or improve SEO effect, accurately obtaining the category name, description, and link is an indispensable part of our daily operation.

2025-11-06

How to get the classification list under a specific content model (such as articles, products)?

As an experienced CMS website operation personnel for Anqi, I know the importance of content organization and user experience for the success of the website.Accurately display content categories, not only can help users quickly find the information they are interested in, but also improve the overall SEO performance of the website.Today, we will delve into how to obtain the category list under specific content models (such as articles, products) in AnQiCMS, which is crucial for building clear website navigation, content aggregation modules, and special pages.

2025-11-06

How to correctly generate and display breadcrumb navigation on a page?

As an experienced CMS website operation person in an enterprise, I am very clear about the importance of breadcrumb navigation in improving user experience and website SEO.It not only helps visitors clearly understand their position on the website, but also guides search engines to better understand the website's hierarchical structure.In AnQi CMS, correctly generating and displaying breadcrumb navigation is a fundamental and important content management task.

2025-11-06

How to display a website navigation menu and support multi-level dropdown navigation?

As an experienced CMS website operation personnel of an enterprise, I know that a well-organized and easy-to-use navigation menu is crucial for the website user experience and content discovery.AnQi CMS provides a powerful and flexible navigation management function, which can help us easily set up the main menu of the website and also support multi-level dropdown navigation to meet the needs of complex website structures. ### Backend Navigation Configuration: Build Menu Structure The setting of the navigation menu in AnQi CMS starts from the backend management interface.

2025-11-06

How to get and display the title, content, and link of a specific single-page?

As an experienced CMS website operation person, I know that content is the soul of the website, and how to efficiently and accurately display content is a crucial link in our daily work.In Anqi CMS, a single page usually carries the core information of the company introduction, contact information, service description, etc., and its content often needs to be specifically retrieved and displayed in various corners of the website.Today, let's discuss in detail how to obtain and display the title, content, and link of a specific single page in Anqi CMS.

2025-11-06

How to get the list of the latest published or articles/products under a specified category?

As an experienced AnQiCMS (AnQiCMS) website operator, I am well aware of the importance of content presentation for website user experience and the effectiveness of content marketing.AnQi CMS provides a powerful and flexible template tag system that allows us to easily retrieve and display various types of articles and product lists, whether it is for the latest content updates or for special topic displays under specific categories, all can be achieved through simple configuration.

2025-11-06

How to display the title, content, images, and other detailed information of the current content on an article or product detail page?

As a senior security CMS website operator, I know that the content detail page is a core component of the website, carrying the important mission of displaying key information such as products and articles to users.A well-designed, comprehensive detail page that not only effectively conveys content value but also enhances user experience and SEO performance.Strong and flexible template tags provided by Anqi CMS, allowing us to easily control the display of each item on the page.

2025-11-06

How can you easily obtain and display the link and title of the previous and next articles on the article detail page?

As an experienced website operator familiar with AnQiCMS, I fully understand the importance of effectively guiding users to browse and discover more content in content management.The navigation of the previous/next article on the article detail page not only can significantly improve user experience and prolong the time users stay on the site, but also helps to optimize the internal link structure of the website, which is very beneficial for SEO.I will elaborate in detail on how to conveniently and quickly obtain and display the links and titles of the previous and next articles on the article detail page of AnQiCMS.--- ###

2025-11-06