How to customize the display layout of the article detail page, including images, descriptions, and custom parameters

Calendar 👁️ 65

In AnQi CMS, the display layout of the article detail page has extremely high flexibility, whether it is to display the core content of the article, beautiful pictures, or customized business parameters, the system provides an intuitive and powerful way to help you meet your personalized needs.This is due to AnQiCMS's template engine similar to Django syntax, which separates content from design, allowing even users without a strong programming background to adjust layouts through simple tags.

Understanding the composition of the article detail page

In AnQiCMS, the detail page of an article (or product, or other content model) is usually controlled by a specific template file. By default, these template files are located in/templateIn the corresponding content model folder under the directory, for example, the detail page of the article model may correspondarchive/detail.html. The system also allows you to set independent templates for specific categories or specific articles, by specifying the template filename in the background, for examplearchive/detail-123.htmlIt will be specifically used for articles with ID 123, or when choosing a custom template during article editing, such asdownload.html.

To customize the layout of the article detail page, the core is to understand how to call the various data of the article in these template files. AnQiCMS provides a wealth of template tags, the most commonly used and critical of which isarchiveDetailandarchiveParams.

Display of core content customization

The basic components of the article detail page are title, content, and summary. In the template, you can directly{{archive.字段名}}or usearchiveDetailuse tags to retrieve and display this information.

  1. Title and description:The title of the article (Title) and description (Description) is the first piece of information that users encounter. You can easily present them on the page in the following way:

    <h1>{{archive.Title}}</h1>
    <p>{{archive.Description}}</p>
    

    Or use:archiveDetailTags:

    <h1>{% archiveDetail with name="Title" %}</h1>
    <p>{% archiveDetail with name="Description" %}</p>
    
  2. Article content:The detailed content of the article (Content) is usually the focus of the user. Since the content may contain HTML tags, to ensure they are parsed correctly by the browser and not displayed as plain text, you need to use|safeFilter. If your content uses a Markdown editor and you want it to be rendered as HTML on the front end, you can use it withrender=trueparameter. At the same time, to optimize loading performance, you can utilizelazyto add lazy loading attributes to the image parameter.

    <div class="article-content">
        {% archiveDetail articleContent with name="Content" render=true lazy="data-src" %}
        {{articleContent|safe}}
    </div>
    

    here,articleContentis the variable name you define for the content,render=trueRepresents converting Markdown to HTML,lazy="data-src"It will contain the content ofimg srcattribute is replaced withdata-src, making it convenient for front-end JS to implement image lazy loading.

  3. Picture display:The images on the article detail page usually include cover images (thumbnails, large images) as well as images in the article content. AnQiCMS provides different tags and fields for these:

    • Cover Image (Logo) and thumbnail (Thumb):If the article is set with a cover image, it can be directly called:
      
      <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
      <img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />
      
    • Group Image (Images):If the article is associated with multiple images (such as the carousel on the product detail page),ImagesThe field will return an array of image URLs. You can useforloop through and display them:
      
      <div class="product-gallery">
          {% archiveDetail productImages with name="Images" %}
          {% for img_url in productImages %}
              <img src="{{img_url}}" alt="产品图" />
          {% endfor %}
      </div>
      
      These images will be processed according to the rules in the background "Content Settings" (such as WebP conversion, automatic compression, thumbnail generation method), but you only need to call its address in the template.
  4. Other standard fields:In addition to the core content mentioned above, you can flexibly display other standard information related to the article, such as publishing time, views, category, and tags.

    • Publish time (CreatedTime):CombinestampToDatetags to format:
      
      <span>发布于:{{stampToDate(archive.CreatedTime, "2006-01-02 15:04")}}</span>
      
    • Views (Views):
      
      <span>阅读量:{% archiveDetail with name="Views" %}</span>
      
    • Category (Category):Can pass througharchive.CategoryAccess category objects, or usecategoryDetailTags:
      
      <span>分类:<a href="{{archive.Category.Link}}">{{archive.Category.Title}}</a></span>
      
    • Label (Tag):UsetagListtag:
      
      <div class="article-tags">
          {% tagList tags with itemId=archive.Id %}
          {% for tag_item in tags %}
              <a href="{{tag_item.Link}}">{{tag_item.Title}}</a>
          {% endfor %}
          {% endtagList %}
      </div>
      

Make full use of custom parameters

The strength of AnQi CMS lies in its flexible content model functionality, which allows you to add an arbitrary number of custom fields for different types of content, and these fields can also be displayed on the article detail page.

  1. Backend settings: Create a custom fieldNavigate to AnQiCMS backend内容管理 -> 内容模型. Select the content model you want to add custom parameters to (for example, 'Article Model' or 'Product Model'), click 'Edit'.In the "Content Model Custom Field" area, you can add various types of fields according to business needs, such as single-line text (for "author", "source"), numbers (for "price", "inventory"), multi-line text (for "product features"), and single/multi/select dropdowns (for "color", "size" etc.).

    For example, add a single-line text field named "Product Model" with the parameter nameproduct_modelor a 'production date' date field.

  2. Template call:archiveParamsTagOnce custom parameters are defined in the background content model, you can use them in the article detail page template.archiveParamsLabel to retrieve and display this data.

    • Traverse all custom parameters:If you want to display all custom parameters of the article, you can use aforto loop througharchiveParamsReturn the parameter list:

      <div class="custom-params">
          <h3>附加信息</h3>
          {% archiveParams params %}
          {% for item in params %}
          <p>
              <span>{{item.Name}}:</span> <!-- 参数的中文名称 -->
              <span>{{item.Value}}</span> <!-- 参数的值 -->
          </p>
          {% endfor %}
          {% endarchiveParams %}
      </div>
      

      The advantage of this method is that it does not require prior knowledge of all custom field names, and the template has a strong universality.

    • Call specific custom parameters:It is more common to only display one or a few specific custom parameters. AnQiCMS supports direct access to them by field name, just like accessing built-in fields:

      <p>产品型号:{{archive.product_model}}</p>
      <p>生产日期:{{archive.production_date}}</p>
      

      Or use:archiveDetailTags:

      <p>产品型号:{% archiveDetail with name="product_model" %}</p>
      <p>生产日期:{% archiveDetail with name="production_date" %}</p>
      

      This method is more accurate, suitable for displaying specific information at specific positions on the page.For example, the product details page may need to place the 'model number' below the title, while 'color', 'size', and other attributes are displayed as a list of product properties.

Actual operation: modify the template file

  1. Determine the location of the template file:Find the corresponding detail page template file based on your content model. For example, for article models, it is usuallytemplate/您的模板名称/archive/detail.htmlIf you have specified a custom template for a specific article or category, please edit the file.
  2. Backup file:Before making any changes, be sure to back up the original template file to prevent any unexpected situations.
  3. Edit template:You can use the "Template Design" feature in AnQiCMS backend to edit template code online, and you can also download the template file to your local computer, modify it with your preferred code editor, and then upload it to overwrite.
  4. **Save and Test

Related articles

How to retrieve and display the article list in the template and control the number of articles displayed per page?

When using AnQiCMS to manage website content, it is an operational requirement to flexibly display article lists on the front-end page.Whether it is the latest dynamic on the homepage, the collection of articles under the category page, or the content aggregation page with pagination function, AnQiCMS provides powerful and easy-to-use template tags to help us achieve these functions.Today, let's delve into how to efficiently retrieve and display the article list in AnQiCMS templates and accurately control the number of articles displayed per page.### Core: `archiveList` tag

2025-11-08

How does AnQiCMS implement the switching and display of multilingual content to enhance the international user experience?

In today's globalized digital world, a website that can present its content in multiple languages undoubtedly can greatly expand its user base and significantly enhance the user experience.AnQiCMS as a powerful content management system, fully considers the needs of international operation, and provides a flexible and efficient mechanism to switch and display multilingual content.### Why is multilingual content so important? Imagine a user from Japan visiting your website. If they can read product descriptions or service instructions in their native language, their trust and engagement will immediately increase

2025-11-08

How to utilize the flexible content model of AnQiCMS to customize unique display fields for different types of content (such as articles, products)?

AnQiCMS, this is a content management system driven by the Go language, which performs very well in content management, especially its flexible content model function.As website operators, we often need to publish various types of content, such as detailed product introductions, professional technical articles, vivid case studies, and so on.Each content has its unique display requirements and information structure.Traditional content management systems may require cumbersome secondary development to meet these differences, but AnQiCMS's flexible content model is exactly born to solve this pain point, allowing us to easily customize

2025-11-08

How to correctly call and display the title and content of the article in the template?

When using AnQiCMS to build and manage websites, the title and content of articles are core elements. Their correct invocation and display are directly related to the visual presentation, user experience, and search engine optimization of the website.Understanding how to efficiently and accurately handle this information in the AnQiCMS template is the key to website content operation and template customization.AnQiCMS's template system adopts syntax similar to the Django template engine, which provides great flexibility and customizability for content display.In the template, you will find that variables are usually enclosed in double curly braces

2025-11-08

How to loop through and output the article list in AnQiCMS template?

AnQiCMS provides a powerful and flexible template system for website content management, among which, the loop traversal and output of the article list is an indispensable core function for building a dynamic website.Whether you need to display the latest articles, category lists, or implement advanced filtering and pagination, AnQiCMS template tags can help you complete it efficiently.

2025-11-08

How to get the current loop item index or remaining item count in an article?

When using AnQi CMS for website content display, we often need to finely control each item in the list.This may include adding numbers to articles, highlighting the first or last item in a list, or applying different styles based on the position of the item in the list.The AnQi CMS template system uses a syntax similar to the Django template engine, where the key to handling list loops is the `for` loop tag.

2025-11-08

How to implement reverse or custom sorting output of AnQiCMS's `for` loop?

The order of website content listings is crucial for user experience and information delivery.Whether it is news updates, product displays, or article archives, flexibly controlling the output order of lists is a common demand in website operation.AnQiCMS provides a powerful and easy-to-use template engine, allowing us to easily control the arrangement of lists, including reverse order and sorting by specific rules.### AnQiCMS Template Engine Basics The AnQiCMS template system adopts the syntax style of the Django template engine, using concise tags and variable declarations

2025-11-08

How to display the default prompt information when the article list obtained through `archiveList` is empty?

When using Anqi CMS to build a website, we often need to display lists of articles, products, or other content.These lists are usually dynamically retrieved and rendered using such template tags as `archiveList`.}However, if a list is empty for various reasons (such as temporarily no content under a category, or empty search results), the user experience will be greatly reduced if the page is just empty.

2025-11-08