How to display the single page content of a specified ID in Anqi CMS, such as 'About Us'?

Calendar 👁️ 53

In Anqi CMS, whether it is to display a corporate profile like "About Us" or static content such as "Contact Information", "Terms of Service", the single-page feature is very practical.It allows you to create independent pages that do not belong to any category and provides a flexible way to control the display of these pages.

To make the Anqi CMS display the single page content of a specified ID, you will mainly use the built-in template tags and the page management function of the background.This makes it very convenient to customize exclusive layouts at any location on the website or for specific single-page sites.

1. Understand the single page function of AnQi CMS

The single-page design of Anqi CMS is intended to manage those contents that are relatively fixed and independently existing.For example, a company's 'About Us' page usually includes a company profile, development history, corporate culture, etc. This content does not update or categorize as frequently as articles or products, but it is an indispensable part of the website.

AnQi CMS provides a special management entrance for these single pages, allowing you to easily create, edit, publish these pages in the background, and finely control their titles, content, SEO information, and even display templates.

2. PassedpageDetailLabel precise call to a single page content

In the AnQi CMS template system,pageDetailThis is a key tag used to retrieve detailed information about a single page. This tag is very powerful, and you can use it in any template file on the website (such as the homepage, sidebar, article detail page, etc.) to call its content based on the ID of the single page or its custom URL alias (token).

For example, you would like to display a brief introduction of the "About Us" single page in the sidebar of the website homepage. Assuming you know the ID of the "About Us" single page is5You can write the code like this in the template:

{# 假设“关于我们”单页面的ID是5,pageDetail标签将获取该单页的所有信息,并赋值给pageData变量 #}
{% pageDetail pageData with id="5" %}
    {# 在调用之前,最好检查一下pageData是否存在,避免因ID错误导致页面报错 #}
    {% if pageData %}
        <div class="sidebar-about-us">
            <h3><a href="{{ pageData.Link }}">{{ pageData.Title }}</a></h3>
            <p>{{ pageData.Description }}</p>
            {# 如果想显示单页面的完整内容的一部分,通常需要使用过滤器来截取文本,例如: #}
            {# <p>{{ pageData.Content|striptags|truncatechars:100 }}</p> #}
            <a href="{{ pageData.Link }}" class="more-link">了解更多</a>
        </div>
    {% endif %}
{% endpageDetail %}

In this code block:

  • {% pageDetail pageData with id="5" %}: is the core part. It tells the system to look up the ID of5A single page, and assign all its available fields (such as title, link, description, content, etc.) topageDatathis variable.
  • {{ pageData.Title }}/{{ pageData.Description }}/{{ pageData.Link }}These are the callspageDatathe way to assign specific fields in the variable.
  • {% if pageData %}This is a good habit to determine whether the single-page data is successfully obtained, to avoid errors when the data does not exist.

If you want to display the content of the single-page template file itself (for example, when the user clicks on the "About Us" link in the navigation bar), since the system already knows that the current page is this single page, you do not need to specify an ID and can call it directly:

{# 这是“关于我们”单页面的专属模板文件,比如可能位于 /template/您的主题/page/about.html #}
{% pageDetail pageContent %}
    <h1>{{ pageContent.Title }}</h1>
    <div class="main-content">
        {# **注意:** 单页面内容通常包含HTML富文本,为了正确显示HTML结构,务必使用 `|safe` 过滤器。 #}
        {{ pageContent.Content|safe }}
    </div>
    {% if pageContent.Images %}
        <div class="gallery">
            {% for image_url in pageContent.Images %}
                <img src="{{ image_url }}" alt="{{ pageContent.Title }}">
            {% endfor %}
        </div>
    {% endif %}
{% endpageDetail %}

3. Customize a dedicated template for the specified single page

The single-page feature of AnQi CMS not only supports calling through ID, but also allows you to specify a dedicated template file for a specific single page to achieve a more personalized display effect.This is very useful for pages that need a unique layout for the 'About Us' and 'Contact Us' sections.

The general steps are as follows:

  1. Create or edit a single page in the background:

    • Log in to the AnQi CMS backend, go to the 'Page Resources' under 'Page Management.'
    • Create a new page or edit an existing page, such as 'About Us.'
    • In the page editing form, find the field named "Single Page Template."
    • Here, you can enter a custom template filename, for exampleabout.html. The system will load the specified template first when accessing this single page according to this setting.
  2. Prepare to customize the template file:

    • According to the Anqi CMS template convention, the template files for a single page are usually stored in your theme directory.page/in the folder.
    • For example, if your theme name isdefaultAnd you set the "About Us" single page template in the background.about.htmlThen you need to./template/default/page/Create a file namedabout.html.
    • in thisabout.htmlIn the file, you can use the way described in the above "Display content in a single-page self-template"pageDetailtags to retrieve and display page data.

The advantage of this method is that you do not need to hardcode IDs in each reference to a single page, but rather the display method is determined by the page URL itself and the backend template settings, which greatly improves management efficiency and template reusability. In addition, you can also set a "custom URL" for single pages in the backend to make the access address more semantically meaningful, such as setting the URL for "About Us"./about-us.html.

Through the above two methods, whether it is to flexibly call the information of a single page with a specified ID on other pages, or to design a unique display template for a specific single page, Anqi CMS provides a clear and easy-to-use solution to help you easily manage the static content of your website.


Frequently Asked Questions (FAQ)

Q1: I created a "About Us" single page and wrote the content, but the content is not displayed completely or HTML tags are displayed when accessed on the front end. What's the matter?A1: This is likely because you did not use it when displaying single-page content in the template|safeFilter. The content of a single page is typically rich text, containing HTML tags.In the AnQi CMS template system, to prevent potential security issues (such as XSS attacks), all content retrieved from the database is automatically escaped by default, which means that HTML tags will be displayed as plain text.You need to call the content field (such as{{ pageContent.Content }}when added}|safea filter such as{{ pageContent.Content|safe }}This will inform the system that the content is safe and can be parsed and displayed as HTML.

Q2: I want to add a link to 'About Us' in the website's navigation bar, how should I operate?A2: You can configure it in the 'Background Settings' -> 'Navigation Settings' of the Anqi CMS backend.Select the navigation category you need to edit (such as "top navigation"), then add a new navigation link.In the 'Link Type' select 'Category Page Link', then find and select the 'About Us' single page you created.The system will automatically generate the correct link address for you.

Q3: Can I use different layouts for different single pages (for example, the "About Us" page has a sidebar, and the "Contact Us" page does not have a sidebar)?A3: Of course. Anqi CMS provides the 'Single Page Template' feature to achieve this.You can edit each single page in the background by specifying a unique template filename in the "Single Page Template" field (for example, "About Us" is specified asabout.html“Contact us” specified ascontact.html)。Then, in the topic you are currently discussing,template/your_theme/page/Under the directory, create these corresponding template files and design a unique layout in each file.This is when the system loads the specified template for each single page that the user visits, to implement different page layouts.

Related articles

How does Anqi CMS handle and display remote images, is it downloaded locally or directly referenced?

In website content management, effective image processing is crucial for improving page loading speed, user experience, and even SEO performance.AnQiCMS (AnQiCMS) provides flexible and practical strategies for handling remote images referenced in content, mainly manifested in two ways: downloading them to the local server for management or directly referencing the original link of the remote image.Both of these methods have their own focus, meeting the needs of different operation scenarios.**The core processing mechanism of AnQi CMS for remote images** AnQi CMS encounters remote image links in the content editor

2025-11-08

How to build and display an online comment form and its custom fields in Anqi CMS?

Aqii CMS provides a powerful and flexible online message function, which not only allows you to build a basic contact form, but also enables you to customize various fields according to business needs, thereby collecting more accurate user feedback.Below, we will explore how to easily build and display these comment forms in Anqi CMS. ### In AnQi CMS backend, configure the message form and custom fields To start building your online message form, you first need to log in to the AnQi CMS backend interface. 1. **Access the Message Management Module:** Log in to the backend after

2025-11-08

How does Anqi CMS display the website visitor's comment list and its reply relationship?

When building and maintaining an active website, visitor interaction is a crucial aspect.The comment system not only enhances the discussion热度 of the website content, strengthens user stickiness, but also brings new content to the website and has a positive impact on search engine optimization (SEO).AnQiCMS (AnQiCMS) fully understands this, and therefore its built-in comment feature provides strong and flexible support for displaying comment lists, handling reply relationships, and managing comments.

2025-11-08

How to implement the hierarchical display of custom navigation menus in Anqi CMS templates?

To implement hierarchical display of custom navigation menus in AnQi CMS is an important link to improve the user experience and content organization of the website.AnQiCMS provides flexible backend configuration and powerful template tags, allowing users to easily build clear and easy-to-navigate multi-level navigation menus. ### Customize Navigation Menu in Backend To achieve hierarchical display of the navigation menu, you first need to make the corresponding configuration in the AnQiCMS backend.In the background management interface, find the "Background Settings" menu under the "Navigation Settings" option

2025-11-08

Does AnQi CMS support the display of mathematical formulas and flowcharts in article content?

In content creation, especially in technical articles, academic papers, or project documents, we often need to present complex mathematical formulas and clear flowcharts to enhance the professionalism and readability of the content.For users of AnQiCMS, this is indeed a very practical need.Then, does Anqi CMS support displaying mathematical formulas and flowcharts in article content?The answer is affirmative, and it is not complex to implement. AnQi CMS provides flexible and diverse content management methods for content creators, one of which is the built-in Markdown editor.

2025-11-08

How to get and display the list of friend links in Anqi CMS?

In website operation, friendship links (also known as friend links) are an important component for improving website authority, increasing external traffic, and promoting interaction between websites.A well-maintained list of friendship links, which can not only increase the external links of the website and have a positive effect on SEO, but also provide users with more relevant information and improve the user experience.AnQi CMS knows its importance and provides an intuitive and user-friendly backend management interface and convenient template calling method, allowing you to easily obtain and display the list of friend links. We will introduce in detail how to implement this feature in Anqi CMS.--- ##

2025-11-08

How does the "Full Site Content Replacement" feature of AnQi CMS affect the final display of published content?

In the daily operation of website management, content updating and maintenance is a continuous and crucial aspect.AnQiCMS (AnQiCMS) understands this need and therefore provides a powerful and efficient feature - 'Full Site Content Replacement'.This feature is not a simple modification of the front-end display, but a deep and immediate modification at the database level of published content, which has a direct and comprehensive impact on the final display effect of the website content.What is the "site-wide content replacement" feature?The "All-site Content Replacement" feature of Anqi CMS, as the name implies

2025-11-08

How to display different content blocks based on conditions in the AnQi CMS template?

In AnQi CMS template design, displaying or hiding content blocks based on different conditions is a key ability to achieve dynamic website effects and enhance user experience.Using the built-in template syntax and rich tag features, we can easily build flexible and versatile pages that respond to different situations.The Anqí CMS template engine adopts a syntax similar to Django, which makes conditional judgment and loop control very intuitive and easy to learn.

2025-11-08