How to call and display the detailed content and images of a specific page in AnqiCMS on the front page?

Calendar 👁️ 58

In AnQiCMS, it is actually much simpler than you imagine to call and display the detailed content and images of a specific single page on the front page.The powerful template tag system of AnQiCMS, especially the tags designed for single-page design, allows you to easily achieve this.

Understanding the single-page function of AnQiCMS

Firstly, we know that AnQiCMS provides an independent "page management" module, which allows us to create independent single pages like "About Us", "Contact Information", or "Service Introduction".This page's content, images, SEO information, etc., can all be managed centrally through the backend.And when displaying on the front end, we just need to make good use of the template tags provided by AnQiCMS, and we can flexibly present these contents to the users.

AnQiCMS's template system uses syntax similar to Django, using{{变量}}to output data,{% 标签 %}to handle logic and call functions. The core of calling single-page content ispageDetail.

core: usingpageDetailLabel to call single page details

pageDetailThe label is specifically used to obtain detailed data of a single page. Whether you want to obtain information about the current single page being visited, or specify the content of a certain single page, it can handle it.

In most cases, when a user directly accesses a single page (such as by clicking on a navigation menu to enter the "About Us" page), AnQiCMS will automatically identify the single page ID of the current page. At this time, you do not need to specify the ID additionally, and can use it directlypageDetailThe label can obtain various information of the current single page.

For example, to display the title of the current single page on the page:

<div>单页标题:{% pageDetail with name="Title" %}</div>

And if you need to call the content of a specific single-page (such as the "About Us" page with ID 10) on a non-single-page detail page (such as a module on the homepage), you can specify it like this:

{% pageDetail aboutUsPage with id="10" %}
<h2>{{ aboutUsPage.Title }}</h2>
<p>{{ aboutUsPage.Description }}</p>

Here, we useid="10"The parameter specifies the single-page ID to be called and stores the obtained data inaboutUsPagethis variable, then through{{ aboutUsPage.Title }}and{{ aboutUsPage.Description }}to display the title and description.

Except through ID, if your single page has set a custom URL alias (you can set it in the background "Page Management" when editing a single page, for exampleabout-us), you can also retrieve and cycle through them using thetokento call with parameters:

{% pageDetail contactPage with token="contact-us" %}
<h3>联系我们:{{ contactPage.Title }}</h3>
<div class="content">{{ contactPage.Content|safe }}</div>

Display detailed content and images of a single page

Detailed content and images of a single page are its core components.pageDetailTags provide rich fields for a comprehensive display.

1. Display the content of a single page

The main part of a single page is usually its main content. This content is edited by a rich text editor in the background and may contain HTML tags.Therefore, when outputting on the front end, in order for these HTML tags to be correctly parsed and displayed with styles, we need to use|safefilter.

{% pageDetail pageContent with name="Content" %}
<div class="page-content">
    {{ pageContent|safe }}
</div>

If you have enabled the Markdown editor in the background and want to render Markdown content on the front end,pageDetaillabel'sContentThe field will be translated by default. You can also add it manually if neededrender=trueorrender=falseParameter.

2. Call single page image

A single page usually includes a main image, thumbnails, and even a group of images. AnQiCMS provides corresponding fields for easy access.

  • Main image (Logo):It is usually used for the cover or the main visual element of a single page.

    {% pageDetail pageLogo with name="Logo" %}
    {% if pageLogo %}
    <img src="{{ pageLogo }}" alt="{% pageDetail with name="Title" %}" class="page-main-image" />
    {% endif %}
    

    Here we use oneifJudgment, to ensure that the image is output when it exists, to avoid invalid image links on the page.

  • Thumbnail (Thumb):If you have uploaded a thumbnail for a single page in the background or if the system has automatically generated a thumbnail, you can accessThumbthe field.

    {% pageDetail pageThumb with name="Thumb" %}
    {% if pageThumb %}
    <img src="{{ pageThumb }}" alt="{% pageDetail with name="Title" %}" class="page-thumbnail" />
    {% endif %}
    
  • Slide group image (Images):Some single pages may need to display a set of images, such as a carousel or gallery.ImagesThe field will return an array of image URLs, you need to useforloop to traverse and display them.

    {% pageDetail pageGallery with name="Images" %}
    {% if pageGallery %}
    <div class="page-gallery">
        {% for imageUrl in pageGallery %}
        <img src="{{ imageUrl }}" alt="{% pageDetail with name="Title" %} - {{ forloop.Counter }}" />
        {% endfor %}
    </div>
    {% endif %}
    

    Hereforloop.CounterYou can get the index of the current element in the loop, which is convenient for adding differentalttext or other properties.

Comprehensive example: building a complete single-page detail page

Assuming we have a 'About Us' single page, ID 10, with a URL aliasabout-usWe would like to have a separate template filetemplate/default/page/detail.htmlThis is the default detail template path of AnQiCMS page where all information is displayed.

{% extends 'base.html' %} {# 继承您的基础布局文件 #}

{% block title %}
    <title>{% tdk with name="Title" siteName=true %}</title>
{% endblock %}

{% block content %}
<div class="container page-container">
    <h1 class="page-title">{% pageDetail with name="Title" %}</h1>

    {# 显示主图片 #}
    {% pageDetail mainLogo with name="Logo" %}
    {% if mainLogo %}
    <div class="page-header-image">
        <img src="{{ mainLogo }}" alt="{% pageDetail with name="Title" %}" />
    </div>
    {% endif %}

    {# 显示单页内容 #}
    {% pageDetail pageContent with name="Content" %}
    {% if pageContent %}
    <div class="page-detail-content">
        {{ pageContent|safe }}
    </div>
    {% else %}
    <p>抱歉,此单页内容为空。</p>
    {% endif %}

    {# 显示幻灯片组图 #}
    {% pageDetail pageImages with name="Images" %}
    {% if pageImages %}
    <div class="page-image-gallery">
        <h3>相关图片:</h3>
        {% for imgUrl in pageImages %}
        <img src="{{ imgUrl }}" alt="{% pageDetail with name="Title" %}图集{{ forloop.Counter }}" class="gallery-item" />
        {% endfor %}
    </div>
    {% endif %}

    {# 还可以调用其他字段,例如描述或自定义字段 #}
    {% pageDetail pageDescription with name="Description" %}
    {% if pageDescription %}
    <div class="page-description">
        <p>简介: {{ pageDescription }}</p>
    </div>
    {% endif %}

    {# 如果有自定义字段,例如“团队成员”,且调用字段名为"team_members" #}
    {% pageDetail teamMembers with name="team_members" %}
    {% if teamMembers %}
    <div class="page-custom-field">
        <h4>团队成员: {{ teamMembers }}</h4>
    </div>
    {% endif %}

</div>
{% endblock %}

This code first calls the current page title as the page.titleCombine the website name to optimize SEO. Then display the main image, content, gallery, and description in order.

Related articles

How to use AnqiCMS's single page list tag to flexibly display independent pages such as 'About Us' on the front end?

In modern website operations, pages like "About Us", "Contact Information", and "Terms of Service" are independent pages that carry the basic information and brand image of the website. Although they are not updated often, they are crucial.AnqiCMS provides a flexible single-page management feature, combining its powerful template tag system, we can easily display these independent pages on the front end and customize them as needed.

2025-11-09

How to accurately call and display the detailed information of a specific category in AnqiCMS on the front page, including the description and Banner image?

In AnqiCMS (AnqiCMS), the need to accurately call and display detailed information about a specific category on the front page, such as the category description and its exclusive Banner image, is a common requirement.This can make the structure of the website content clearer, as well as improve user experience and the website's SEO performance.Benefiting from AnqiCMS flexible template tag system, achieving this goal is actually very direct. We mainly use a core template tag——`categoryDetail`.

2025-11-09

How to use the AnqiCMS category list tag to display article/product categories by level or model on the front end?

It is crucial to organize and present information efficiently in website content management.AnqiCMS provides a powerful template tag system, where the `categoryList` tag is a core tool for displaying articles or product categories flexibly.By mastering the use of this tag, users can easily build a clear and functional classification navigation on the front end, whether displaying by level or filtering according to the content model (such as articles, products), they can handle it with ease.### Get to know `categoryList`

2025-11-09

How to implement breadcrumb navigation in AnqiCMS templates and control the display of the home page name and document title?

In website operation, a clear navigation path is crucial for user experience and search engine optimization (SEO).Breadcrumb Navigation as an auxiliary navigation method can directly tell users where the current page is in the website structure, effectively reduce the bounce rate, and help search engines better understand the website hierarchy.

2025-11-09

How to use AnqiCMS document list tags to display the latest, hot, or specified category of articles/products on the front page?

In AnqiCMS, flexibly displaying website content is the key to improving user experience and meeting operational needs.Whether you want to highlight the latest articles on the homepage, display popular products in the sidebar, or customize content lists for specific columns, AnqiCMS's powerful document list tags can help you a lot.By skillfully using these tags, you can easily achieve a diverse presentation of content, making your website more dynamic and attractive.### Core Tag: `archiveList`

2025-11-09

How to accurately display the detailed content of a specific AnqiCMS document on the front page, including the title, description, and image?

AnQiCMS (AnQiCMS) leverages its flexible content model and intuitive template tag system, allowing you to easily manage the display of website front-end content.It is particularly important to understand the core mechanism and common tags when we need to present the detailed content of a specific document accurately on the front page, such as the title, description, full text, and related images.### Understanding the content structure of Anqi CMS In Anqi CMS, all content is organized based on the "content model", such as common article models, product models, etc.

2025-11-09

How to display the 'Previous' and 'Next' documents of the current document on the front page to enhance the user's browsing experience?

In AnQiCMS (AnQiCMS), adding "Previous" and "Next" navigation links to the front-end document pages is an important means to enhance user browsing experience and extend user stay time.When a user finishes reading an article, these links can guide them naturally to discover more related content, avoid interrupting page browsing, and effectively reduce the bounce rate, which also helps to enhance the overall weight of the website's content. AnQi CMS as a rich-featured Go language content management system, built-in with a powerful template tag system, allowing website operators to flexibly control content display. Among which

2025-11-09

How to display the AnqiCMS related document list on the front page to increase content relevance and user stay time?

In content operation, we all hope that users can stay longer on the website and browse more content.An精心 crafted article is indeed important, but how to connect it with other relevant content to form a content matrix is the key to improving user experience and reducing bounce rate.Imagine, after a user finishes reading an article about 'AnQi CMS Core Features', if the page below automatically recommends 'How to Build an E-commerce Site with AnQi CMS' or 'AnQi CMS Template Creation Tutorial', wouldn't it be more attractive for them to continue exploring?

2025-11-09