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

Calendar 👁️ 79

As an experienced website operation expert, I know that in a high-efficiency content management system like AnQiCMS, mastering template tags is the key to improving operational efficiency and achieving personalized content display. Today, let's delve into a very practical tag -pageDetailIt can help us easily obtain and display the independent page content on the website.

Unveiling AnQiCMS'spageDetailTag: easily control the single page content display

In modern website operations, pages such as "About Us", "Contact Information", "Privacy Policy", and "Service Agreement" play a crucial role.They are not only a window for conveying core information to visitors and building trust, but also an indispensable part of search engine optimization (SEO).Aqiji CMS fully understands the importance of these pages and provides powerful and easy-to-usepageDetailTags, allowing content operators to manage and display these single-page contents flexibly without touching complex code.

pageDetailThe core function of the tag is to accurately obtain and output detailed data of the specified independent page. Imagine that your website has multiple independent pages, and you may need to display their titles, summaries, or full content in different template areas, at this timepageDetailWill be of use.

pageDetailBasic syntax of tags

pageDetailThe general syntax structure of the tag is very intuitive, it follows the style of the Django template engine and combines the Go language features of AnQiCMS, ensuring high performance and security:

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

This syntax may seem complex at first glance, but once we break it down, we find it very friendly.

  • {% pageDetail ... %}: This is the start of the tag, indicating that we are callingpageDetailFeature.
  • 变量名称(Optional): You can specify a temporary variable name for the data you obtain, such asmyPageIf omitted, the tag will directly output the content of the specified field.The benefit of assigning data to a variable is that you can refer to this variable multiple times in the subsequent part of the template, or perform more complex processing, such as in aifCheck if it exists in the judgment or combine it with other data to display.
  • with: This is a delimiter used to introduce subsequent parameters.
  • name="字段名称"This is a crucial parameter that determines which specific data field you need to retrieve from an independent page, such as the title, content, and links.
  • id="1"ortoken="about-us"These are used to specify which independent page you want to retrieve parameters for.

MasterpageDetailcore parameters

To accurately retrieve the single-page data you need,pageDetailThe label provides several key parameters that allow you to flexibly locate and extract information.

  1. Parameters to locate a specific page:idortoken

    When you need to accurately select a certain page from among many independent pages to display its details,idandtokenthe parameters become particularly important. They are the 'identity card' of the target page you specify.

    • idParameterThis is located by the numeric ID of an independent page. For example, if the "About Us" page in the back-end has an ID of5, then you can useid="5"Get its data. This method is very useful when you need to refer to a fixed ID page, such as displaying a specific page in the footer navigation.

      {# 获取ID为5的单页标题 #}
      <div>关于我们标题:{% pageDetail with name="Title" id="5" %}</div>
      
    • tokenParameter: Compared to numeric ID,tokenThe parameter allows you to locate through the page's "URL alias" (i.e., custom URL). For example, the URL alias for your "Contact Us" page is set tocontact-usthentoken="contact-us"It will be more readable and memorable. In AnQiCMS, setting meaningful custom URL aliases for single pages is not only good for SEO, but also makes template calls more semantic.

      {# 获取URL别名为"contact-us"的单页链接 #}
      <a href="{% pageDetail with name="Link" token="contact-us" %}">联系我们</a>
      

    In most cases, if you call in the current independent page templatepageDetailAnd not specifyidortokenthe tag will automatically retrieve the details of the current page. But if you need to reference a specific single page across pages, you must useidortokenSpecify clearly.

  2. Specify the parameters for getting data fields:name

    This ispageDetailThe core of the tag, which tells the tag which part of the page information you want to get.nameParameters support a variety of commonly used fields, covering all aspects of independent pages:

    • Id: The unique numeric identifier of the page.
    • Title: The title of the page, usually the content of the H1 tag.
    • LinkThe page's access link.
    • DescriptionA brief description of the page, often used for SEO meta descriptions or page summaries.
    • Content: The main content of the page, including all text, images, formats, and other content edited in the backend editor.
    • Logo: The main image or thumbnail large image of the page (if set).
    • ThumbThe thumbnail of the page (if set).
    • ImagesThe slide group image of the page (if multiple images are set, it will return an array of image URLs).

    For example, to get the title and content of a page:

    {# 获取指定ID页面的标题并赋值给pageTitle变量 #}
    {% pageDetail pageTitle with name="Title" id="10" %}
    <h1>{{ pageTitle }}</h1>
    
    {# 获取指定ID页面的内容并赋值给pageContent变量 #}
    {% pageDetail pageContent with name="Content" id="10" %}
    <div class="main-content">{{ pageContent|safe }}</div>
    

    Pay special attention hereContentThe call of the field. Since the page content usually contains HTML tags (such as paragraphs, images, links, etc.), in order to make the browser parse and render these HTML tags correctly and not treat them as plain text, you must use|safeFilter. Moreover, if your page content is written in a Markdown editor in the background, you can also addrender=trueParameter, let AnQiCMS automatically convert Markdown syntax to HTML before output to ensure the correct display of content.

    {# 渲染Markdown内容并使用|safe过滤器确保HTML正确解析 #}
    {% pageDetail pageContent with name="Content" id="10" render=true %}{{ pageContent|safe }}
    

    ForImagesfield, because it may contain multiple images, so it will return an array of image URLs. You need to combineforloop tags to iterate and display these images:

    {% pageDetail pageBannerImages with name="Images" id="10" %}
    {% if pageBannerImages %}
        <div class="page-slider">
            {% for imgUrl in pageBannerImages %}
                <img src="{{ imgUrl }}" alt="页面图片">
            {% endfor %}
        </div>
    {% endif %}
    
  3. Parameters under multi-site environment:siteId

    AnQiCMS supports multi-site management, which is very convenient for enterprises with multiple brands or sub-sites. If you are in a multi-site environment, you need to callfrom a non-current siteof a certain independent page data, can be usedsiteIdThe parameter is used to specify the site ID explicitly. Usually, if you only operate one site or call the data of the current site, this parameter does not need to be filled in.

    {# 获取ID为10的页面的标题,但它属于站点ID为2的站点 #}
    <div>其他站点页面标题:{% pageDetail with name="Title" id="10" siteId="2" %}</div>
    

Actual Application: Build a "About Us" page

Let's tie together with an example of a common "About Us" pagepageDetailTag Usage:

Suppose we have a URL alias namedabout-usThe "About Us" page, we need to display the company profile, detailed content, and possibly a corporate culture photo album on the page.

``twig <!DOCTYPE html>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{# 设置页面标题 #}
<title>{% tdk

Related articles

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

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-page (also known as independent page) plays an indispensable role, whether it is to showcase corporate culture in "About Us", provide a communication bridge in "Contact Us", or introduce various service pages, they are all important windows for users to obtain core information.

2025-11-07

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

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

Is the `id` parameter of the `pageDetail` tag required?

## AnQiCMS `pageDetail` tag's `id` parameter: Optional flexible art As an experienced website operations expert, I am well aware of the importance of the flexibility of content management system templates in improving operational efficiency and website performance.AnQiCMS (AnQiCMS) boasts its concise and efficient architecture, which is also reflected in the design of template tags.

2025-11-07