How to list all or specified types of single pages in AnQiCMS template?

Calendar 👁️ 50

Managing and displaying single-page content in AnQiCMS is a common requirement for website operations, especially for static content such as 'About Us', 'Contact Information', and 'Terms of Service'.As an experienced AnQiCMS operations personnel, I know that efficient use of template tags can greatly enhance the flexibility of content publishing and the maintenance efficiency of the website.This article will detail how to list all or specified types of single pages in the AnQiCMS template.

Understand the single page mechanism in AnQiCMS

In AnQiCMS, Single Page is a special page type independent of content models such as articles and products.They are usually used to display relatively fixed content that does not involve classification or list aggregation.AnQiCMS provides a dedicated "Page Management" feature (located under "Page Resources") to create and edit these single pages.On the template level, AnQiCMS provides intuitive and powerful tags for single-page calls.

List all single pages

To retrieve and display all single pages created on the website, we need to use the built-in AnQiCMS.pageListLabel. This label will return an array object containing all the single page data, and we can iterate over this array to display the information of each single page one by one.

Generally,pageListThe usage of tags is as follows, among whichpagesis the variable name defined for the single page list obtained:

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

In the above code,itemrepresents a single page variable in each iteration. We can accessitemThe attribute to retrieve detailed information of a single page, for example:

  • item.Id: Unique ID of the single page.
  • item.Title: Single page title.
  • item.LinkThe access link of the single page.
  • item.Description: Brief introduction of the single page.
  • item.Content: Full content of a single page.
  • item.Logo: Large image of a single page (if set).
  • item.Thumb: Thumbnail of a single page (if set).

This method is very suitable for displaying all single-page links uniformly at the bottom of a website, in the sidebar, or on some aggregation page.

List single pages of specified type

In some cases, we may need to control the display of a single page more precisely, for example, to only display the "About Us" page, or to exclude a specific page. AnQiCMS combinespageDetailTags andforLooping conditions provide us with this flexibility.

1. Get the single-page details of the specified ID or URL alias

If we clearly know the ID or URL alias of a single pagetoken), you can use it directlypageDetailtag to retrieve its details. This is very useful when you need to embed the content of a specific single page into another page.

for example, get the ID of1Single page title:

<div>关于我们页面标题:{% pageDetail with name="Title" id="1" %}</div>

Or through a URL aliasabout-usGet its content:

{% pageDetail aboutPage with name="Content" token="about-us" %}
<div>关于我们页面内容:{{aboutPage|safe}}</div>

This method is direct and efficient, suitable for single page calls with fixed and unique content.

2. Exclude or select specific pages from all single-page lists

When we usepageListAfter obtaining all single-page items, you canforLoop addedifmake conditional judgments based on the single-pageId/TitleorLinkUse properties to filter out the pages we want or exclude the ones we don't want.

For example, to list all single pages but exclude pages with ID as1The "About Us" page:

<ul>
{% pageList pages %}
    {% for item in pages %}
        {% if item.Id != 1 %} {# 排除ID为1的页面 #}
        <li>
            <a href="{{ item.Link }}">{{item.Title}}</a>
            <p>{{item.Description}}</p>
        </li>
        {% endif %}
    {% endfor %}
{% endpageList %}
</ul>

Again, we only want to display a single page whose title contains the word 'service':

<ul>
{% pageList pages %}
    {% for item in pages %}
        {% if item.Title contains "服务" %} {# 假设存在“contains”过滤器或使用其他逻辑 #}
        <li>
            <a href="{{ item.Link }}">{{item.Title}}</a>
            <p>{{item.Description}}</p>
        </li>
        {% endif %}
    {% endfor %}
{% endpageList %}
</ul>

It should be noted that,item.Title contains "服务"This advanced string matching may require combining with the filters provided by the AnQiCMS template engine (such asfilter__name:paramOr Go languagestrings.ContainsFunction (if the template engine supports it). In AnQiCMS's Django template syntax, it is usually usedifThe comparison of statements combined with variables, or with the help of preprocessed data. If it is simply a match of ID or alias, the aforementioneditem.Id != 1method is completely feasible.

3. Use Custom URL Aliases and Custom Templates

AnQiCMS allows setting a "custom URL" and a "single-page template" for single pages. This means we can assign a business-related URL alias to a single page through backend configuration, such asabout-usCorresponding to the "About Us" page), and call it through this alias in the template. Furthermore, if certain single pages require a completely unique layout, they can be assigned exclusive template files (such aspage/about.html), so that the system will automatically load the corresponding custom template when accessing these pages.This approach is not directly used for list filtering, but provides the ability to highly customize the display of a specific single page.

Template file organization and rendering

According to the AnQiCMS template convention, the default template for a single page detail page ispage/detail.html. If a custom template is specified for a single page, for example namedpage/about.htmlThen, when accessing the single page, it will renderabout.htmlUnderstanding these rules helps us organize template files more effectively and accurately call and display single page content across different pages.

The AnQiCMS single-page management mechanism is flexible and powerful, whether it is to list all single pages uniformly or to call or filter specific pages accurately, it can be achieved by using combinationspageListandpageDetailTags, as well as appropriate template logic judgment to implement. This allows website operators to easily meet various content display needs, ensuring high-quality presentation of website content.


Frequently Asked Questions (FAQ)

1. Why do I usepageListThe label does not display any single page content?

IfpageListThe label does not display any content, please first check whether a single page has been created in the 'Page Management' of AnQiCMS backend.Make sure these pages are in the "Published" status, not in drafts or the recycling bin.Secondly, check if the path to your template file is correct, as well as whether the syntax of the tags conforms to the AnQiCMS Django template engine specifications.

2. How to display thumbnails next to each item in the single page list?

InpageListIn the loop, eachitemAll variables includeThumbfield used to store the thumbnail address of a single page. You can<li>add a<img>Label, andsrcset the attribute to{{item.Thumb}}to display the thumbnail. It is best to use it before addingif item.ThumbMake a judgment to avoid breaking images when there are no thumbnails.

3. How can I make some single-page websites not be indexed by search engines?

For single pages that you do not want to be indexed by search engines, you can find the SEO-related settings in the AnQiCMS back-end when editing the single page, which usually includes options such as "nofollow" or "noindex". If you call it directly in the template and the page does not generate a separate URL (such as just embedded content), you may consider in<a>the tag withrel="nofollow"Attribute, or on the pageheadPartially add<meta name="robots" content="noindex, nofollow">Tag, which is usually achieved through custom templates or usingtdkThe SEO field of the tag can be realized. AnQiCMS mentioned the TDK settings, includingtag-tdk.mdThe document mentioned the TDK settings, includingCanonicalUrl,Indirectly supports SEO control, you can also set SEO titles, keywords, and descriptions for specific pages in the background, and use these fields to generatemeta.

Related articles

How to get and display detailed information of a specified category in AnQiCMS template?

As an experienced CMS website operation personnel of an enterprise, I know that it is crucial to display content efficiently and accurately in templates for the attractiveness and SEO performance of the website.Category information is the core of website architecture, able to accurately obtain and present on the front-end page, not only improving user experience, but also providing a clear structure for search engine crawling.Today, let's discuss in detail how to obtain and display detailed information of a specified category in the Anqi CMS template.

2025-11-06

How to list category information in AnQiCMS templates by module or parent relationship?

A detailed guide to listing category information by module or parent relationship in AnQiCMS templates As an experienced AnQiCMS website operator, I know the importance of content organization.A clear, easy-to-navigate classification system not only improves user experience, but is also the foundation of SEO optimization.AnQi CMS, with its flexible content model and powerful template tag system, provides us with multiple ways to display category information in website templates according to module or parent-child relationship.This article will delve into how to make use of these features to build an efficient classification list.###

2025-11-06

How to generate breadcrumb navigation path in AnQiCMS templates?

As an experienced CMS website operation personnel, I am well aware of the importance of a clear and efficient website navigation system for user experience and search engine optimization (SEO).Breadcrumbs navigation is an important part of website auxiliary navigation, which can intuitively show the user's position on the website and provide a convenient return path.The AnQi CMS with its flexible template engine makes it easy and efficient to generate breadcrumb navigation in website templates.

2025-11-06

How to build a multi-level navigation menu in AnQiCMS template?

Hello, I am the familiar Anqi CMS website operation veteran that you know.Navigation menus are of great importance in daily website maintenance and content optimization, as they are not only guides for users to browse the website but also crucial for search engines to understand the website structure.Today, let's delve into how to build a flexible and efficient multi-level navigation menu in the AnQiCMS template.

2025-11-06

How to display the detailed content of a specified single page in AnQiCMS template?

In AnQiCMS website operation, the Single Page (Page) feature is a very practical module, which allows us to create and manage static pages independent of dynamic content such as articles or products, such as "About Us", "Contact Information", or "Service Introduction" and so on.These pages usually contain relatively fixed and important information, which needs to be presented to visitors in a clear and direct manner.As a senior operator of AnQiCMS, I know how to effectively use the template mechanism to accurately control the display of these single pages to meet the diverse design and content needs.

2025-11-06

How to filter and display the document list in AnQiCMS template according to categories, models, recommended attributes, etc.

As an experienced AnQiCMS website operations manager, I fully understand the importance of efficient content management and flexible display.In AnQiCMS, the filtering and display of document lists are indispensable functions for building dynamic websites.Whether it is to display the latest articles under a specific category, or to differentiate products and news according to the content model, or to highlight recommended content, AnQiCMS's powerful template tags can help us easily achieve these needs.

2025-11-06

How to get the detailed information of the current document in AnQiCMS template (such as title, content, thumbnail)?

As an experienced AnQiCMS website operator, I am well aware of the importance of flexibly obtaining and displaying content in templates.AnQiCMS is a powerful template engine that makes content creation, editing, and publishing efficient and convenient.Today, we will delve into how to obtain detailed information about the current document in the AnQiCMS template, such as the title, content, and thumbnail, to help you better customize the front-end display of the website.

2025-11-06

How to display the link to the previous and next document in the AnQiCMS template?

As an experienced security CMS website operator, I am well aware of the importance of website content navigation for user experience and search engine optimization.Clear and convenient navigation not only guides users to delve into the website content, effectively extending their stay time, but also helps build a perfect internal link structure, enhancing the search engine's crawling efficiency and content weight.Today, we will discuss in detail how to flexibly display the previous and next document links of the current document in the AnQiCMS template.### Template Basics Review The template engine in AnQiCMS uses something similar to Django

2025-11-06