In the operation of AnQiCMS website, the single-page (Page) feature is a very practical module that allows us to create and manage static pages independent of dynamic content such as articles or products, such as 'About Us', 'Contact Information', or 'Service Introduction', etc.These pages usually contain relatively fixed and important information, which needs to be presented to the visitors in a clear and direct manner.As an experienced operator of AnQiCMS, I am well aware of how to effectively use the template mechanism to accurately control the display of these single pages to meet diverse design and content needs.

Core Concept:pageDetailTag

AnQiCMS provides a dedicated template tagpageDetailThis tag is used to retrieve and display detailed information for a single page. It is the core control for outputting the content of a single page. ThroughpageDetailLabel, we can use the unique identifier (ID) of the page or a custom URL alias (tokenTo accurately specify the single page to be displayed and extract the various fields we need, such as title, content, link, images, etc.

Display the specified single page content in the template

The most common method to display specific single-page content in an AnQiCMS template is to utilizepageDetaillabel'sidortokenParameter.

For example, if you want to display the content with ID at a specific location on the website,1The "About Us" page, you can use the following syntax in your template file to get its title and content:

{% pageDetail aboutPage with id="1" %}
    <h1 class="page-title">{{ aboutPage.Title }}</h1>
    <div class="page-content">
        {{ aboutPage.Content|safe }}
    </div>
    <a href="{{ aboutPage.Link }}" class="page-link">了解更多</a>
{% endpageDetail %}

In this code block:

  • pageDetail aboutPage with id="1"Instruct the system to retrieve the ID of1Single page data, and assign it to the name ofaboutPage.
  • {{ aboutPage.Title }}Used to display the title of the single page.
  • {{ aboutPage.Content|safe }}Used to display the main content of the single page. It should be noted that,|safeThe filter is crucial here, it tells the template engine to output the content as safe HTML instead of escaping, which is necessary for content containing rich text editors.
  • {{ aboutPage.Link }}It will output the access link to the single page.

In addition to using the ID, you can also use the page's custom URL alias (tokenSpecify a single page. For example, if the alias of your "Contact Us" page is set tocontact-usHow to call:

{% pageDetail contactPage with token="contact-us" %}
    <h2 class="section-title">{{ contactPage.Title }}</h2>
    <p>{{ contactPage.Description }}</p>
    <div>
        {{ contactPage.Content|safe }}
    </div>
{% endpageDetail %}

Not specifiedidortokenIn the case of parameters,pageDetailThe label will try to get the single-page data corresponding to the current URL. This is in the detail template of the single-page itself (such aspage/detail.htmlIt is very convenient to use, you can directly display the information of the current page without any additional parameters.

Custom single page template

AnQiCMS provides a flexible template customization mechanism, allowing you to design unique designs for different single-page applications.In the background "Page Management" area, when you edit or create a single page, there will be a "Single Page Template" field.By default, all single pages will use/template/{你的模板目录}/page/detail.htmlthis file.

But if you want a specific single page to have a completely different layout or style, you can create a dedicated template file for it. For example, if you have an ID of5The "Service Process" page, and you want it to use a template namedservice-flow.htmla special template, you can follow the following steps:

  1. In the directory of the template you are currently using (for example/template/default/),service-flow.htmlThe file. This file can contain completely customized HTML structure and style.
  2. In the AnQiCMS backend, go to 'Page Management', find the ID of5Edit the "Service Process" page.
  3. Fill in the "Single Page Template" field.service-flow.html.
  4. Save the page.

This, when the user visits the 'Service Process' page, the system will no longer load the defaultpage/detail.htmlbut will use the one you specifiedservice-flow.htmlTo render content. AnQiCMS also supports naming templates according to ID, for examplepage/detail-5.htmlThe system will automatically recognize and apply. This method is particularly suitable for situations where unique displays are needed for a few important pages.

Rendering content processing

As mentioned earlier, the content of a single page is usually entered through a rich text editor, which may contain HTML tags. To ensure that this content is rendered correctly on the page,