How to get and display all the content and associated images of a specific single page?

Calendar 👁️ 65

In Anqi CMS, a single page is an important part of the website's content structure, such as 'About Us', 'Contact Information', and so on.Effectively obtain and display all the content of these single pages and associated images, which is crucial for the communication of website information and visual expression.AnQi CMS provides an intuitive backend management and flexible template tags, making this process very convenient.

Easily set single page content and images in the background

First, we need to create and edit single page content in the Anqi CMS admin system.This is usually performed in the 'Page Resources' under the 'Page Management' module.When you add or edit a single page, you will see a series of fields to fill in the content:

You can enter the "page name", which will be the title of the page.Next, 'Single Page Summary' can be used to provide a brief overview of the page.The most important content is reflected in the "Single Page Content" area, where it supports rich text editors, can insert text, links, tables, etc., and can also directly embed images.

For associated images, AnQi CMS provides several ways to manage: First is the "thumbnail", where you can upload a main thumbnail for a single page, which is usually used for list display or as the main visual of the page.In addition, there is also a very practical "Banner Image" option, which allows you to upload multiple images, which are usually used as a carousel at the top of the page or as a gallery of images on the page.By these settings, you can easily organize the text and image content on a single page.

Retrieve and display single page information in the front-end template

After the background content setting is completed, the next step is how to display these contents in the website's frontend template.AnQi CMS adopts a simple template tag system, making content calls very intuitive.

Invocation of core text content

To obtain detailed content of a single page, we mainly usepageDetailTemplate tag. This tag can help us get various information from a specific single page.

Suppose you are editing a page namedpage/detail.htmlA single page detail template, or you have specified a custom template for a specific single page. In the template, you can directly use{% pageDetail with name="Title" %}to get the page title, or use{% pageDetail with name="Description" %}to get the page summary.

For the main content of a single page, which is the rich text you fill in the background "Single Page Content" editor, you can use{% pageDetail pageContent with name="Content" %}{{pageContent|safe}}to retrieve and display. Here is the|safeIt is a very critical filter that tells the template engine that this content is safe HTML, which does not need to be escaped, thus ensuring that the HTML format and style of the input from the background can be correctly parsed and rendered by the browser. If your single-page content is written using a Markdown editor and you want it to be rendered as HTML on the front end, you canContentthe tag withrender=trueparameters, for example{% pageDetail pageContent with name="Content" render=true %}{{pageContent|safe}}.

Display related images

Images are an important component of the single-page visual presentation, and Anqi CMS also provides a clear calling method.

If you uploaded a single-page "thumbnail", you can{% pageDetail with name="Logo" %}get the address of the large thumbnail, or through{% pageDetail with name="Thumb" %}get the address of the small thumbnail. Then embed them into<img>label'ssrcAs for the attribute:<img src="{% pageDetail with name="Logo" %}" alt="{% pageDetail with name="Title" %}" />

For the "Banner image" (i.e., multiple related images) uploaded on the backend, Anqi CMS will provide them as an image array. You need to usepageDetailLabel combinationforLoop to traverse and display these images. Usually, we would do it like this:

{% pageDetail pageImages with name="Images" %}
<ul>
    {% for item in pageImages %}
        <li>
            <img src="{{ item }}" alt="{% pageDetail with name='Title' %}" />
        </li>
    {% endfor %}
</ul>

This code will get all related Banner image addresses and generate one for each image.<li>Label, embedded<img>Label, implement a simple image list display.

Specify the single page to display.

In most cases, when a user visits a single page, the template automatically identifies the content of the current page and displays it. But if you need to call a specific function on other pages or in certain scenarios,Not currentContent of a single page,pageDetailTags also provide flexibility. You can useidortokenparameters to specify the single page you want to retrieve:

  • Specify through ID: {% pageDetail aboutUsTitle with name="Title" id="10" %}Hereid="10"It will retrieve the title of the single page with ID 10.
  • Specify through URL alias (token): {% pageDetail contactUsContent with name="Content" token="contact-us" %}Heretoken="contact-us"Will fetch the single page content with the URL alias "contact-us".

This allows you to precisely control which single page content is displayed on the page.

Complete example: a display of the 'About Us' page.

Assuming we have a single-page "About Us", with ID 5 and a custom URL alias ofabout-usThe backend has set the title, introduction, detailed content, a main Logo image, and multiple Banner images. Here is a simplified code example of how to fully display these contents in a template.

{# 页面头部引入公共模板,通常包含TDK、CSS等 #}
{% include "partial/header.html" %}

<main class="page-container">
    <article class="page-content-wrapper">
        <h1 class="page-title">{% pageDetail with name="Title" %}</h1>
        <p class="page-description">{% pageDetail with name="Description" %}</p>

        {# 展示主要内容,注意使用 |safe 过滤器 #}
        <section class="main-content">
            {% pageDetail pageMainContent with name="Content" %}
            {{ pageMainContent|safe }}
        </section>

        {# 如果有主Logo图片,可以这样展示 #}
        {% pageDetail pageLogo with name="Logo" %}
        {% if pageLogo %}
            <div class="page-logo">
                <img src="{{ pageLogo }}" alt="{% pageDetail with name='Title' %}" />
            </div>
        {% endif %}

        {# 展示多张Banner图,使用循环遍历 #}
        {% pageDetail pageImages with name="Images" %}
        {% if pageImages %}
            <div class="page-gallery">
                <h3>页面图集</h3>
                <div class="image-carousel">
                    {% for image_url in pageImages %}
                        <img src="{{ image_url }}" alt="{% pageDetail with name='Title' %}-图{{ forloop.Counter }}" />
                    {% endfor %}
                </div>
            </div>
        {% endif %}

    </article>
</main>

{# 页面底部引入公共模板,通常包含JS、页脚信息等 #}
{% include "partial/footer.html" %}

Some practical tips

  • Custom single page template:The AnQi CMS supports specifying independent template files for individual pages. You can fill in the "Single Page Template" field when editing a single page in the background.page/about_us.htmlThen create the corresponding template file, so that this page will use this exclusive template.
  • Image optimization:In the "Content Settings" in the background, you can enable features such as automatic image compression and conversion to WebP format, which helps to improve page loading speed and user experience.
  • SEO friendly:The single-page also supports setting independent SEO titles, keywords, and descriptions. Proper use of these fields can help your single-page achieve better rankings in search engines.

By using the above method, you can easily manage and display all content and associated images on a single page in Anqi CMS, creating a rich and beautiful website.


Frequently Asked Questions (FAQ)

How can I

Related articles

How to display all or part of a single-page list on a website?

In website operations, we often need to display some independent, fixed-content pages, such as 'About Us', 'Contact Information', or some policy descriptions, etc.In Anqi CMS, these are called "single pages". Effective management and presentation of these single pages not only makes the website structure clearer but also enhances the user experience.Next, we will discuss how to flexibly display all or part of a single-page list on a website.### **Understanding the Creation and Management of Single Pages (Backend Operations)** Before Starting the Frontend Display

2025-11-08

How to retrieve and display detailed information of a specific category (such as description, Banner image)?

In Anqi CMS, it is crucial to flexibly obtain and display detailed information about categories, such as descriptions, Banner images, or thumbnails, which is essential for building a website rich in content and visually appealing.Whether it is necessary to display a brief introduction on the category list page or to reference the promotional picture of a specific category on a specific page, Anqi CMS provides intuitive and powerful template tags to help you meet these needs. To get detailed information about the category, we mainly rely on the `categoryDetail` template tag.This tag is specifically designed to extract data for each category

2025-11-08

How to display a category list based on content model or parent-child relationship?

AnQi CMS is an efficient enterprise-level content management system that provides great flexibility in content organization and display.For many websites, how to display a category list based on different content models or the hierarchical relationship of categories is a very common and important need.This concerns not only the organization structure of the website content, but also directly affects the user experience and SEO effect.In Anqi CMS, implementing such a display is not complicated.The built-in template tags provide us with powerful functions, allowing us to easily control the output of the classification list

2025-11-08

How to correctly display the breadcrumb navigation path on the content page?

Breadcrumb Navigation is a very common and practical navigation method on websites, which can clearly display the current position of the user in the website hierarchy, just like breadcrumbs scattered in the forest guiding the way home.For users, breadcrumb navigation not only helps them quickly understand the hierarchical relationship of the current page in the entire website, but also facilitates their return to the previous level or higher-level pages, greatly enhancing the user experience of the website.At the same time, for search engine optimization (SEO)

2025-11-08

How to display a document list based on different conditions (such as categories, recommended properties)?

In Anqi CMS, flexibly displaying website content is the key to improving user experience and meeting operational needs.Whether based on the category of the article or the recommended attributes of the content, the system provides powerful and easy-to-use template tags that allow you to easily customize the display of the document list. ### Core Tool: `archiveList` Document List Tag The core tool used in AnQi CMS to control the display of document lists is the `archiveList` tag.It allows you to filter, sort, and limit the number of displayed documents based on multiple conditions

2025-11-08

How to display the complete article content on the article detail page, including lazy-loaded images?

How to elegantly display full content and lazy loading images on article detail pages in AnQi CMS In website content operations, the article detail page is an important touchpoint for users to obtain information and gain a deeper understanding of brands and products.A well-designed, fast-loading, and comprehensive article detail page that can greatly enhance user experience and effectively assist in SEO optimization.For users who use Anqi CMS, taking full advantage of its powerful template tag system can easily realize the complete presentation of article content, and combine modern web technologies to implement lazy loading of images, making your website both beautiful and efficient.###

2025-11-08

How to display mathematical formulas and flowcharts with Markdown in AnQiCMS?

In content operations, sometimes we need to display complex mathematical formulas or clear flowcharts, especially in technical articles, data reports, or educational content.AnQiCMS with its powerful Markdown editor, provides us with the convenience to meet this requirement.By simple configuration and importing the necessary library files, you can perfectly present these professional contents on the website front-end.### Enable AnQiCMS Markdown Editor Firstly, let AnQiCMS recognize and handle Markdown formatted content

2025-11-08

How to display the links to the previous and next articles on the document detail page?

When browsing website content, users often want to be able to navigate easily between related articles.For example, after reading a news article or tutorial, you can quickly click to go to the "previous" or "next" article to maintain the continuity of reading.This not only improves user experience and reduces the bounce rate, but also has a positive effect on the internal link structure of the website and search engine optimization (SEO).AnQiCMS (AnQiCMS) is an efficient content management system that provides a very simple and intuitive way to implement this function.We do not need complex backend programming

2025-11-08