How to display all or part of a single-page list on a website?

Calendar 👁️ 56

In website operation, we often need to display some independent pages with relatively fixed and unchanged content, such as "About Us", "Contact Information", or certain policy descriptions, etc.In Anqi CMS, these are called 'single pages'. Effective management and display of these single pages not only makes the website structure clearer but also improves the user experience.

Next, we will explore how to flexibly display all or part of a single-page list on a website.

1. Understand the creation and management of single-page (backend operations)

Before starting the front-end display, it is first necessary to ensure that the corresponding single-page content has been created and perfected in the Anqi CMS backend.

  1. Enter Page Management:Log in to the AnQi CMS backend, you can find the 'Page Resources' option under 'Page Management' in the left-hand navigation bar.
  2. Create or edit a single page:Here, you can add a new single page or edit an existing one. Each single page includes the following core information:
    • Page name:This is the title of the single page, which will also be displayed directly on the front end.
    • Custom URL:To ensure SEO-friendliness and link aesthetics, it is recommended to set a concise and meaningful custom URL for each single page (for example,about-us/contactWhen your pseudo-static rule includes{filename}field, this custom URL will take effect.
    • Single page content:This is the main content of the page, you can use the rich text editor to edit, supporting mixed text and images.
    • SEO information (title, keywords, description):For each single page, you can set the SEO title, keywords, and description individually to help search engines better understand and index the page content.
    • Display order:By adjusting the display order of the numbers, you can control the default arrangement of the single page in the list. The smaller the number, the closer it is to the front.
    • Single page template: This is a very powerful feature. By default, the single-page will usepage/detail.htmlThis is a general template. If you want a single page to have a unique design, you can specify a custom template file in the background (for example, for the "About Us" page specifyabout.htmlAs long as the file exists in your templatepagein the directory).

After completing the creation and content filling of a single page, we can start showing them on the front end of the website.

Second, display all single-page lists on the website

If you want to display all published single pages in an area (such as footer navigation or sidebar), Anqi CMS provides a concise template tagpageListto achieve.

pageListThe label will retrieve all the single-page data you have created. You can use it like this in the template file:

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

Code interpretation:

  • {% pageList pages %}This is the core tag, it will retrieve all single page data from the database and assign it to a namedpages.
  • {% for item in pages %}We use aforto loop throughpagesEach single page in the variable, the data of each single page will be traversed in the loop.itemVariable access.
  • {{ item.Link }}This will output the access link of the current single page.
  • {{ item.Title }}This will output the title of the current single page.

Through this simple code snippet, your website can dynamically display the list of all single pages.

3. Flexible display of part of the single page list

Sometimes, we do not need to display all single pages, or we may want to handle some single pages in a special way. Anqi CMS provides various flexible ways to achieve this purpose.

1. Filter and exclude through template logic

You canforUsing a loopifConditionally filter or exclude specific single pages. For example, if you want to exclude the single page with ID 1:

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

You can also filter by title or other fields:

<ul>
{% pageList pages %}
    {% for item in pages %}
    {# 仅展示标题包含“关于”的单页面 #}
    {% if item.Title|contain:"关于" %} 
    <li>
        <a href="{{ item.Link }}">{{ item.Title }}</a>
    </li>
    {% endif %}
    {% endfor %}
{% endpageList %}

We used herecontainFilter (referencefilter-contain.md), it can determine if a string contains specific keywords.

2. Display details of a specific single page

If you want to display the content of a specific single page directly in a certain area of the website instead of a list link, you can usepageDetailThe tag allows you to accurately retrieve the details of a single page by ID or a custom URL alias.

For example, directly display the introduction of the "About Us" page on the homepage:

<div class="about-us-summary">
    <h2>{% pageDetail with name="Title" token="about-us" %}</h2>
    <p>{% pageDetail with name="Description" token="about-us" %}</p>
    <a href="{% pageDetail with name="Link" token="about-us" %}">了解更多</a>
</div>

Code interpretation:

  • {% pageDetail with name="Title" token="about-us" %}Through custom URL aliasabout-usGet the title of the single page.
  • {% pageDetail with name="Description" token="about-us" %}: Get the description of the single page.
  • {{ item.Content|safe }}: If you need to display the full content (which may include HTML), please make sure to use|safeFilter to prevent HTML content from being escaped (reference)filter-safe.md)

3. Use the "single-page template" feature on the backend to implement a specific design

As mentioned earlier, when editing a single page in the background, you can specify a separate template file for it.This means that when the user accesses this single page, the system will automatically load the template you specify, thus achieving a completely personalized design.

For example, specify the template file for the "Contact Us" page with ID 5contact.htmlThen you just need to make suretemplate/你的模板目录/page/contact.htmlThe file exists and the 'Single Page Template' field of this single page is filled in under the 'Page Management' in the backgroundcontact.htmlJust do it.

Four, Important Tips and **Practice

  • Location of the template file: The default single page detail template istemplate/你的模板目录/page/detail.html. If you have customized a single-page template (for examplecontact.html), it should be placed intemplate/你的模板目录/page/directory.
  • Static rules:Make sure that your website's pseudo-static rules include the single-page rules, which are usuallypage===/{filename}.htmlIn a similar form, this is how a friendly URL is generated (refer tohelp-plugin-rewrite.md)
  • SEO optimization:Fully utilize the SEO title, keywords, and description fields of the background single-page, and optimize the SEO independently for each single page.
  • Display order:In the "Page Management" section on the backend, adjusting the "Display Order" field can conveniently control the default sorting of a single page in the list.
  • Multi-site support:If you have used the multiple site management feature of Anqi CMS and want to call data from other sites, you canpageListorpageDetailthe tag withsiteIdspecify the parameter (for example,{% pageList pages with siteId="2" %})

By using the above method, you can flexibly display all or a specific part of the single-page list on the Anqi CMS website, meeting the display needs of different scenarios.


Frequently Asked Questions (FAQ)

  1. How to adjust the display order of a single-page in the list?You can edit each single page in the "Page Resources" -> "Page Management" section of the Anqi CMS backend, find the "Display Order" field.By setting different numbers to control sorting, the smaller the number, the closer the single page will be displayed at the top of the list.

  2. What should I do if my single-page content contains HTML code but it is escaped when displayed on the front end?When you output single-page content in the front-end template (for example{{ item.Content }}or{% pageDetail with name="Content" %})when, if the content contains HTML tags, for safety reasons, the system will escape them by default. If you confirm that these HTML contents are safe and you want them to be parsed and displayed normally, please add|safefor example:{{ item.Content|safe }}.

  3. I want to design a completely different layout for a single page, can Anqi CMS achieve this?Of course you can. When editing this single page in the background, there is a "Single Page Template" field. You can enter a custom template file path here (for exampleabout_us_custom.htmlMake sure this file exists in your templatepageUnder the directory (for exampletemplate/default/page/about_us_custom.htmlThis way

Related articles

How to retrieve and display detailed information of a specific category (such as description, Banner image)?

In Anqi CMS, it is crucial to flexibly obtain and display detailed information about categories, such as descriptions, Banner images, or thumbnails, which is essential for building a website rich in content and visually appealing.Whether it is necessary to display a brief introduction on the category list page or to reference the promotional picture of a specific category on a specific page, Anqi CMS provides intuitive and powerful template tags to help you meet these needs. To get detailed information about the category, we mainly rely on the `categoryDetail` template tag.This tag is specifically designed to extract data for each category

2025-11-08

How to display a category list based on content model or parent-child relationship?

AnQi CMS is an efficient enterprise-level content management system that provides great flexibility in content organization and display.For many websites, how to display a category list based on different content models or the hierarchical relationship of categories is a very common and important need.This concerns not only the organization structure of the website content, but also directly affects the user experience and SEO effect.In Anqi CMS, implementing such a display is not complicated.The built-in template tags provide us with powerful functions, allowing us to easily control the output of the classification list

2025-11-08

How to correctly display the breadcrumb navigation path on the content page?

Breadcrumb Navigation is a very common and practical navigation method on websites, which can clearly display the current position of the user in the website hierarchy, just like breadcrumbs scattered in the forest guiding the way home.For users, breadcrumb navigation not only helps them quickly understand the hierarchical relationship of the current page in the entire website, but also facilitates their return to the previous level or higher-level pages, greatly enhancing the user experience of the website.At the same time, for search engine optimization (SEO)

2025-11-08

How to build and display multi-level navigation menus on a website?

The website navigation menu is a guidepost for users to browse the website content, a well-designed multi-level navigation system can significantly improve user experience, and help visitors quickly locate the required information.A clear, intuitive, and easy-to-use navigation is a key element for the success of a corporate website, product showcase page, or content portal.AnQi CMS is a comprehensive and flexible content management system that provides intuitive backend settings and powerful template tags, allowing you to easily build and manage multi-level navigation menus that meet various needs.

2025-11-08

How to get and display all the content and associated images of a specific single page?

In Anqi CMS, a single page is an important part of the website content structure, such as "About Us", "Contact Information", and so on.Effectively acquire and display all the content of these single pages and associated images, which is crucial for the communication and visual expression of the website.Aanqi CMS provides an intuitive backend management and flexible template tags, making this process very convenient. ### Easily set up single page content and images in the background First, we need to create and edit single page content in the Anqi CMS backend management system. This is usually performed under the 'Page Resources' section in the 'Page Management' module

2025-11-08

How to display a document list based on different conditions (such as categories, recommended properties)?

In Anqi CMS, flexibly displaying website content is the key to improving user experience and meeting operational needs.Whether based on the category of the article or the recommended attributes of the content, the system provides powerful and easy-to-use template tags that allow you to easily customize the display of the document list. ### Core Tool: `archiveList` Document List Tag The core tool used in AnQi CMS to control the display of document lists is the `archiveList` tag.It allows you to filter, sort, and limit the number of displayed documents based on multiple conditions

2025-11-08

How to display the complete article content on the article detail page, including lazy-loaded images?

How to elegantly display full content and lazy loading images on article detail pages in AnQi CMS In website content operations, the article detail page is an important touchpoint for users to obtain information and gain a deeper understanding of brands and products.A well-designed, fast-loading, and comprehensive article detail page that can greatly enhance user experience and effectively assist in SEO optimization.For users who use Anqi CMS, taking full advantage of its powerful template tag system can easily realize the complete presentation of article content, and combine modern web technologies to implement lazy loading of images, making your website both beautiful and efficient.###

2025-11-08

How to display mathematical formulas and flowcharts with Markdown in AnQiCMS?

In content operations, sometimes we need to display complex mathematical formulas or clear flowcharts, especially in technical articles, data reports, or educational content.AnQiCMS with its powerful Markdown editor, provides us with the convenience to meet this requirement.By simple configuration and importing the necessary library files, you can perfectly present these professional contents on the website front-end.### Enable AnQiCMS Markdown Editor Firstly, let AnQiCMS recognize and handle Markdown formatted content

2025-11-08