How to use the `pageDetail` tag to get detailed content and images of a single page (such as "About Us")?

Calendar 👁️ 57

In website operation, pages like "About Us" and "Contact Us" are indispensable, as they carry important information such as corporate culture, contact information, and service introduction.How to present these carefully prepared contents efficiently and beautifully on the website front-end is a skill that every website operator needs to master.For users using AnQiCMS (AnQiCMS)pageDetailTags are the key tools to achieve this goal.

Single page in AnqiCMS: the cornerstone of content

Further understandpageDetailBefore the label, let's get to know the single page in AnqiCMS.In the AnqiCMS backend management interface, you can find the 'Page Management' feature in the 'Page Resources' module.This is where you create and edit all single pages. A single page typically includes the following key information:

  • Page Name (Title): The title displayed on the page.
  • Single page summary (Description)Used to briefly summarize the page content, which is also very helpful for SEO.
  • Single page content (Content): The main text, images, videos, and other rich content of the page. Anqi CMS supports rich text editor, and you can easily edit and format it.
  • Custom URL (Custom URL): You can set a more friendly URL path for a single page, for exampleabout-us/contactThis is very important for improving user experience and SEO.
  • Banner image and thumbnail (Images/Logo/Thumb): Configure the main visual image for the page, used to display on list pages or at the top of the page.
  • Single Page Template (Page Template): Allows you to specify an independent template file for a specific single page to achieve personalized layout.

These background configuration data ultimately need to be presented to the user through template tags, andpageDetailThis is the bridge of this link.

pageDetailTag: a powerful tool for obtaining content on a single page

pageDetailThe tag is a special tag used in the AnqiCMS template engine to obtain detailed content of a single page. Its basic syntax is very intuitive:

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

Among them:

  • 变量名称: This is an optional parameter. If you want to store the data you get in a variable for later repeated use or more complex logical processing, you can specify a variable name (for example,aboutPage)。If not specified, the tag will directly output the value of the corresponding field.
  • name="字段名称": This is a core parameter used to specify which field value you want to get on a single page. For example,name="Title"Get the title,name="Content"Get content.
  • id="1"ortoken="about-us"These two parameters are optional. By default,pageDetailthe tag will automatically retrieve the single-page content corresponding to the current visited page. If you need to getnot the current pageThe specific single-page content (such as displaying a fragment of "About Us" on the homepage), can be accessed by specifying the single-page ID (id) or its custom URL alias (token)to achieve this.

Understood the basic syntax, we can then start to get the detailed content and images of a single page.

Get the text content of a single page

The main text content of a single page is usually stored inContentIn the field. We can get it like this:

{# 默认用法,自动获取当前页面单页的内容 #}
<div>
    {% pageDetail with name="Content" %}
</div>

If you store the content in a variable and want to ensure that HTML tags are parsed correctly (because the backend usually uses a rich text editor), you need to combine|safeFilter. If the background content editor has enabled the Markdown function and you want to render Markdown formatted content into HTML, you need to addrender=trueparameters:

{% pageDetail pageContent with name="Content" render=true %}
<div>
    {{ pageContent|safe }}
</div>

Here, render=trueTell AnqiCMS template engine to convert Markdown content to HTML, and|safeThe filter ensures that the converted HTML code is not escaped again, thus displaying styles and layouts correctly in the browser.

Get the image content of a single page.

The single page can be configured with various image types, including main image, thumbnail, and group images.pageDetailThe tag provides corresponding fields to retrieve these images:

  1. Get the main logo and thumbnail:LogoGenerally used for the main visual image or larger size images on the page, whileThumbit is used to display smaller thumbnails.

    {# 获取单页的主形象图 #}
    <img src="{% pageDetail with name="Logo" %}" alt="{% pageDetail with name="Title" %}" />
    
    {# 获取单页的缩略图 #}
    <img src="{% pageDetail with name="Thumb" %}" alt="{% pageDetail with name="Title" %}" />
    
  2. Get the slide group image (Images) for a single page: If a single page is configured with multiple images, such as for a carousel or album display, these images will be stored inImagesin the field. Due toImagesis an array of image addresses, you need to usefora loop to iterate through and display each image.

    {% pageDetail pageImages with name="Images" %}
    <div class="gallery">
        {% for imageUrl in pageImages %}
            <img src="{{ imageUrl }}" alt="Image {{ forloop.Counter }}" />
        {% endfor %}
    </div>
    

    Here, pageImagesis an array that contains all image URLs. We go throughforit in a loop,imageUrlThe variable will be an image address in the array each time the loop runs,forloop.Counterwhich can be used to display the current image number.

Practice case: Building the "About Us" page.

Let us go through an actual example of an "About Us" page to link together the above knowledge points. Suppose we have a background ID of10or customize the URL alias ofabout-usThe "About Us" page.

{# 引入头部文件,通常包含网站的公共样式和JS #}
{% include "partial/header.html" %}

<main class="main-content">
    <section class="about-hero">
        {# 获取“关于我们”页面的主形象图,通过token指定 #}
        <img src="{% pageDetail with name="Logo" token="about-us" %}" alt="关于我们主视觉" class="hero-image">
    </section>

    <section class="about-intro container">
        {# 获取“关于我们”页面的标题 #}
        <h1 class="page-title">{% pageDetail with name="Title" token="about-us" %}</h1>
        {# 获取“关于我们”页面的简介 #}
        <p class="page-description">{% pageDetail with name="Description" token="about-us" %}</p>
    </section>

    <section class="about-details container">
        {# 获取“关于我们”页面的详细内容,并确保HTML正确渲染 #}
        {% pageDetail pageDetailContent with name="Content" token="about-us" render=true %}
        <article class="content-body">
            {{ pageDetailContent|safe }}
        </article>
    </section>

    <section class="company-gallery container">
        <h2>公司环境</h2>
        {# 获取“关于我们”页面的组图,并以图集形式展示 #}
        {% pageDetail companyPhotos with name="Images" token="about-us" %}
        <div class="image-grid">
            {% for photoUrl in companyPhotos %}
                <img src="{{ photoUrl }}" alt="公司环境图片 {{ forloop.Counter }}" class="grid-item">
            {% endfor %}
        </div>
    </section>
</main>

{# 引入底部文件 #}
{% include "partial/footer.html" %}

In this code, we call it multiple times.pageDetailLabel, respectively obtained the main image, title, introduction, detailed content, and group photos of the "About Us" page, and throughtoken="about-us"Ensure that the specified single-page data is obtained.

Flexible application: Advanced usage and customization

In addition to obtaining the content of the current page,pageDetailThe flexibility of the tag also manifests in the following aspects:

  • Obtaining by specifying ID or TokenAs shown in the above example, you can useid="单页ID"ortoken="单页URL别名"To accurately retrieve any single page content that has been created, regardless of which page the current user is visiting.This is especially useful when you need to display a brief information of a single page on other pages (such as the homepage).
  • Multi-site data callIf you have configured multi-site management in the AnqiCMS backend and want to call single-page data from other sites, you can usesiteIdto specify the target site ID. For example,{% pageDetail with name="Content" id="1" siteId="2" %}The content of the single page with ID 1 of the site ID 2 will be retrieved.
  • Custom single page template: AnqiCMS allows you to set a custom template file for a single page. For example, if your "Contact Us" page needs a special map layout, you can specify a named template in the edit page of that single page in the background.page/contact.htmltemplate. So when the user accesses the "Contact Us" page, the system will automatically apply this custom template, and you just need topage/contact.htmlcallpageDetailTag it and it is.

By flexible applicationpageDetailtags and their parameters, you can easily

Related articles

How to retrieve all documents under a specific Tag and implement pagination using `tagDataList` tag?

In the vast field of content operation, tags (Tags) play a crucial role.They can not only thematize and structure scattered content, but also guide users to explore deeply, improve the efficiency of content discovery, and enhance the overall user experience of the website.As an experienced website operations expert, I am well aware of the powerful capabilities of AnqiCMS (Anqi CMS) in label management and content display.

2025-11-06

How `tagList` tags display the related Tag list of the specified document?

As an experienced website operations expert, I know that how to flexibly and effectively organize and display content in a content management system is the key to improving user experience and search engine optimization (SEO).AnQiCMS (AnQi CMS) offers many powerful functions in this aspect, and the `tagList` tag is an important bridge to connect content and enhance discoverability.Today, let's delve into how to use the `tagList` tag in AnQiCMS to accurately display the associated tag list of a specified document.### Fine-grained content management

2025-11-06

How to get the link, Logo image, and document count in the `categoryList` loop?

As an experienced website operations expert, I am well aware of the importance of an efficient and flexible content management system for daily operations.AnQiCMS with its high-performance architecture based on the Go language and the friendly syntax of the Django template engine, provides us with great convenience.Today, let's explore a very practical technique in website frontend display: how to elegantly obtain the links, Logo images, and the number of documents under each category in the `categoryList` loop.

2025-11-06

how the `categoryList` tag implements nested hierarchical display of multi-level categories?

Sure, as an experienced website operations expert, I am happy to deeply analyze how to implement nested display of multi-level categories in the `categoryList` tag of AnQi CMS and transform it into an article that is easy to understand and practical. --- ## AnQi CMS `categoryList` Tag: Easily Implement Nested Display of Multi-level Categories, Making the Website Structure Clear and Orderly A clear classification system is crucial for user experience (UX) and search engine optimization (SEO) in website operations.

2025-11-06

How to build a multi-level website navigation menu using the `navList` tag and support dynamic display of categories or document links?

As an experienced website operations expert, I am well aware of the importance of a clear and efficient website navigation system for improving user experience, guiding content consumption, and optimizing search engine rankings (SEO), which is self-evident.In AnQiCMS (AnQiCMS) such a well-designed content management system, building flexible and variable navigation menus, and making them able to intelligently display dynamic content, is the key to operators achieving fine-grained content layout.

2025-11-06

How to use the `breadcrumb` tag in the AnQiCMS template to generate breadcrumb navigation?

As an experienced website operations expert, I know that a user-friendly and SEO-optimized website cannot do without a clear navigation structure, and breadcrumb navigation is the key link in this regard.It can not only help users understand their current location, improve the usability of the website, but also provide clear website structure signals for search engines.In AnQiCMS, integrating and using breadcrumb navigation is very simple and efficient, which is mainly due to its built-in `breadcrumb` tag. Today

2025-11-06

How does the `stampToDate` tag format timestamps into any custom date and time format?

## Mastering AnqiCMS `stampToDate`: Easily Customize Time Display Format The way time information is presented is crucial in the daily work of content operation.Whether it is the release date of an article, the time a product is listed, or the moment a comment is submitted, a clear and readable date and time format can greatly enhance the user experience.However, we often get a series of difficult-to-understand Unix timestamps from the database - like the number `1609470335`. Don't worry

2025-11-06

Which conditional judgment operations does the `if` logical judgment tag support in the AnQiCMS template?

As an experienced website operation expert, I am well aware that a powerful and flexible template system is crucial for the effective presentation of website content.AnQiCMS (AnQi Content Management System) takes full advantage of its high efficiency based on the Go language and the grammar features borrowed from Django template engine, providing great convenience for our content operation.In AnQiCMS template development, proficiently using logical judgment tags is the key to achieving dynamic content display and enhancing user experience.Today, let's delve into the various conditional judgment operations supported by the `if` logical judgment tag in the AnQiCMS template

2025-11-06