How to call the detailed information of a specific page in Anqi CMS template?

Calendar 👁️ 74

AnQi CMS, as an efficient and flexible content management system, has provided strong support for us in the field of content operation.In daily website management, single pages (or independent pages) play an indispensable role, whether it is to display corporate culture on "About Us", provide a communication bridge with "Contact Us", or introduce various service pages, they are all important windows for users to obtain core information.Therefore, how to accurately and efficiently call the detailed information of these specific single-page templates has become a key skill that website operators and template developers need to master.

The AnQi CMS template system is designed very well, it draws on many advantages of the Django template engine, making content calls both powerful and intuitive. If you are familiar with{{变量}}Used for output content,{% 标签 %}The syntax for controlling logic, so calling data in Anqi CMS will be an easy task.For such single-page content, the system provides special tags to help us retrieve and display its details.

Core tool:pageDetailIn-depth interpretation of tags

When we need to display the complete content of a specific single page in the template,pageDetailThe tag is our preferred tool. The role of this tag is to extract all detailed data from the corresponding single page according to the identification you provide, and to make it flexible for use in the template.

pageDetailThe basic structure and key parameters of the tag:

{% pageDetail 变量名称 with name="字段名称" id="1" %}

Here are some core points that we should pay attention to:

  1. 变量名称(Optional): You can specify a variable name for the single page information you get, for example:aboutPage)。After specifying, you can call its data through{{aboutPage.字段名}}to call its data. If omitted, the label will directly output the specifiednamefield value, more suitable for simple, direct calls.
  2. name="字段名称"(Optional)This parameter allows you to directly specify the specific field of the single page to be called, such asTitle(Title),Content(Content) etc. If specified变量名称, then thisnameparameter can be omitted and called directly through the variable
  3. id="1"ortoken="your-page-alias"(Key)This is the core way to specify a 'specific single page'.
    • id: Directly specify the unique numeric ID of the page in the background system. For example, if the 'About Us' ID is 1, you can useid="1".
    • tokenThrough a single-page URL alias (usually a string of English characters, such as "about-us") to specify.This is a more readable and SEO-friendly way. When creating a single-page in the background, you can customize this URL alias.
    • If you do not specifyidortoken,pageDetailThe tag will try to get the details of the current page by default (if the current page is a single page).
  4. siteId(Multi-site scenario)If you have enabled the multi-site feature of Anqicms CMS and need to call single-page data from other sites, you cansiteId="站点ID"specify this. Generally, there is no need to set this parameter.

pageDetailA list of fields that can be obtained from a single page:

Anq CMS stores rich field information for each single page, through:pageDetailTags, you can easily access them:

  • Id: The unique numerical identifier of a single page.
  • Title: The title of a single page, usually the large title seen by the user on the page.
  • Link: The access link of a single page.
  • Description: A brief description of a single page, often used in SEO meta tags.
  • Content: The main content of a single page, which may include rich text or Markdown format.
  • Logo: Thumbnail large image address of a single page.
  • Thumb: Thumbnail address of a single page.
  • Images: Slide group image of a single page, this is an array containing multiple image addresses.

How to use templates flexiblypageDetail?

Let's get to know by some actual scenariospageDetailusage.

Scenario one: Display the 'About Us' introduction in the fixed area of the sidebar or bottom

Assuming your website footer needs to display a brief introduction to the "About Us" page, and the "About Us" page's ID is5the URL alias isabout-us.

{# 方法一:通过ID直接调用简介 #}
<div class="footer-about">
    <h4>关于我们</h4>
    <p>{% pageDetail with name="Description" id="5" %}</p>
    <a href="{% pageDetail with name="Link" id="5" %}">了解更多</a>
</div>

{# 方法二:通过URL别名指定,并用变量接收完整信息 #}
{% pageDetail aboutUs with token="about-us" %}
<div class="footer-about">
    <h4>{{ aboutUs.Title }}</h4>
    <p>{{ aboutUs.Description }}</p>
    <a href="{{ aboutUs.Link }}">了解更多</a>
</div>
{% endpageDetail %}

In the above example, we have demonstrated two calling methods.If you need to refer to different fields of the same page multiple times, using variables to receive complete information (method two) will be more concise and efficient.

Scenario two: Display the full content of a specific single page on the homepage (for example, an important announcement)

Assuming you have a single page named 'Latest Announcement' with ID is10,You hope to display the complete content in a specific area on the homepage.

{% pageDetail latestNotice with id="10" %}
<section class="latest-announcement">
    <h2>{{ latestNotice.Title }}</h2>
    <div class="notice-content">
        {# 注意:Content字段可能包含HTML内容,需要使用 |safe 过滤器确保正确渲染,而非转义 #}
        {# 如果后台开启了Markdown编辑器且内容是Markdown,系统会自动转换,但手动 render=true 更明确 #}
        {{ latestNotice.Content|safe }} 
    </div>
    {% if latestNotice.Images %}
    <div class="notice-images">
        {% for img in latestNotice.Images %}
            <img src="{{ img }}" alt="{{ latestNotice.Title }} 图片" />
        {% endfor %}
    </div>
    {% endif %}
    <p><a href="{{ latestNotice.Link }}">查看完整公告</a></p>
</section>
{% endpageDetail %}

Here we not only called the title and content, but also used{% if latestNotice.Images %}to determine if there is a picture group, and through{% for img in latestNotice.Images %}The loop displayed multiple slide images.{{ latestNotice.Content|safe }}It is a very important detail that tells the template engine to treat the content as safe HTML rather than simply escaping it. If your single-page content is entered through a Markdown editor, Anqi CMS will usually automatically convert HTML, but if you want to ensure accuracy or need to manually control the rendering behavior, you canContentField is added when calledrender=trueparameters, for example{{ latestNotice.Content|render:true|safe }}.

Scenario three: Load a custom single-page template based on URL alias

AnQi CMS allows you to set a custom template for specific single pages (set "Single Page Template" in the background single page management), for example, to create a custom template for the "Contact Us" pagepage/contact.htmltemplate for exclusive use.

Intemplate/你的模板目录/page/Create a folder undercontact.htmlFile. When you set a single page template in the backgroundcontact.htmlthe single page will automatically load this template. Incontact.htmlWithin the template, since the current page is this single page, you can use it directlypageDetailThe tag retrieves the details of the current single page without specifyingidortoken:

{# page/contact.html 模板文件内容示例 #}
{% pageDetail currentPage with name="Title" %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>{{ currentPage.Title }} - {% system with name="SiteName" %}</title>
</head>
<body>
    <header>
        <h1>{{ currentPage.Title }}</h1>
    </header>
    <main>
        <p>{{ currentPage.Description }}</p>
        <div class="contact-info">
            {{ currentPage.Content|safe }}
        </div>
    </main>
    <footer>
        {# 调用系统设置中的联系方式 #}
        <p>电话: {% contact with name="Cellphone" %}</p>
        <p>邮箱: {% contact with name="Email" %}</p>
    </footer>
</body>
</html>
{% endpageDetail %}

**Practice and Precautions

  • Uniqueness is crucialWhether throughidOrtokenCall a specific single-page, be sure to ensure that the identifier you use is unique. When creating a single-page in the background, the system will automatically handle itiduniqueness, andtoken(Custom URL alias) must be manually maintained unique.
  • Make good use of|safeFilter: When single page of theContentorDescriptionfield may contain HTML tags, please be sure to use|safefor example, a filter (such as{{ someVariable|safe }}To prevent content from being escaped, ensure that the HTML structure is rendered correctly.
  • The importance of backend configurationBefore calling the specific page information in the template, make sure that the page has been created and published in the "Page Resources -> Page Management" section of the Anqi CMS backend.At the same time, reasonably setting its "custom URL" and "single-page template" will provide more convenience and flexibility for your front-end display.
  • Debugging and testingIn the development process, if you find that the call does not work or displays an error, please first check if the single-page ID or URL alias is correct, then confirm if the template syntax is incorrect, and finally check if the single-page content meets expectations.

By flexibly using AnQi CMS'spageDetailThe label allows us to easily call and display rich information of a specific single-page at any location on the website, thus building a more dynamic and interactive user experience.Mastering this skill will greatly enhance your efficiency in content operation and template development for Anqi CMS.


Frequently Asked Questions (FAQ)

Q1: If I ampageDetailDoes the template report an error if the single page ID or URL alias specified in the tag does not exist?

A1:Generally, the template engine of Anqi CMS is designed to be quite robust, when you go throughpageDetailWhen a tag calls an ID or URL alias that does not exist, it will not directly throw a fatal error causing the page to crash. Instead, the tag will return empty data (i.e., the value of the corresponding field will be an empty string ornilThis means that if you try to access these fields in the template, they will not display any content.In order to provide a better user experience, you can use conditional judgments in the template (such as{% if somePage.Title %}Check if the data exists, only

Related articles

How to format timestamps with the `stampToDate` tag in AnQiCMS template?

As an experienced website operations expert, I know that in daily content management, timestamp formatting is a seemingly simple detail that often troubles many operations personnel.In AnQiCMS such an efficient and flexible content management system, mastering the use of template tags can greatly enhance the professionalism and user experience of content presentation.Today, let's delve into a very practical and key tag in the AnQiCMS template - `stampToDate`, and see how it helps us easily format timestamps.

2025-11-07

How to use `if` and `for` tags for logical judgment and loop traversal in AnQiCMS templates?

As an experienced website operations expert, I am well aware of the importance of a flexible and powerful template system for content management.AnQiCMS leverages its high-performance architecture based on the Go language and support for Django template engine syntax, providing us with great convenience.It is not just a tool for publishing content, but also a powerful tool for us to achieve personalized content display and improve user experience.

2025-11-07

How to deploy AnQiCMS Docker installation tutorial through 1Panel/aaPanel/Baota panel?

As an experienced website operations expert, I fully understand the importance of an efficient, secure, and easy-to-manage content system for a company.AnQiCMS (AnQiCMS) boasts a high-performance architecture based on the Go language, providing an excellent content management experience while also winning the favor of many users with its flexible deployment methods.

2025-11-07

How to install and manage multiple sites on the same server with AnQiCMS?

## AnQiCMS: Easily manage multiple sites on the same server and implement your brand matrix management As an experienced website operations expert, I know that in today's digital age, many companies and content creators may have multiple brands, product lines, or regional sites. How to efficiently and economically manage these content platforms is often a headache.The traditional method may mean deploying a separate system for each site, which consumes a lot of server resources and operation and maintenance efforts.

2025-11-07

What is the basic syntax and necessary parameters of the `pageDetail` tag?

As an experienced website operations expert, I know that proficiently using template tags in a high-efficiency content management system like AnQiCMS is the key to improving operational efficiency and achieving personalized content display.Today, let's delve into a very practical tag - `pageDetail`, which can help us easily obtain and display the content of independent pages on websites.

2025-11-07

What are the respective roles of `variable name` and `field name` when calling the single-page detail?

As an experienced website operation expert, I know that understanding the essence of template tags in a high-efficiency content management system like AnQiCMS is the key to exerting its powerful functions and building flexible pages.Today, let's delve into a common problem encountered when calling single-page details: What are the respective roles of '`variable name`' and '`field name`'?In the AnQi CMS template system, the `pageDetail` tag is specifically used to call up detailed information for a single page.

2025-11-07

How will the content be directly output if the `variableName` of the `pageDetail` tag is not set?

## Unlock the secrets of Anqi CMS single page content output: The power of the simple `pageDetail` tag As an expert in website operations for many years, I know that efficiently and flexibly displaying content is the key to success in daily content management.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, and its simple and efficient template engine is very appealing to me.It provides great convenience in content display, especially for single-page content (such as "About Us", "Contact Information", etc.)

2025-11-07

How to accurately obtain the details of a single page through the single page ID?

As an experienced website operations expert, I know that how to efficiently and accurately obtain the required data in a content management system is the key to improving operational efficiency.In AnQiCMS (AnQiCMS), a single page (or independent page) is often used to display 'About Us', 'Contact Information', 'Service Introduction', and other important but infrequently changing content.Sometimes, we not only need to display the details on the single page itself, but may also need to reference part of the specific page information on other parts of the website (such as the homepage, sidebar).

2025-11-07