How to retrieve and display the title, detailed content, summary, and recommended attributes of an article (document)?

Calendar 👁️ 93

In Anqi CMS, whether it is to display the detailed content of a single article or to preview multiple articles on the list page, flexibly obtaining and displaying the title, detailed content, summary, and recommended attributes of the articles is the foundation of website operation.The design of Anqi CMS makes this process intuitive and efficient, we mainly achieve it through the use of template tags and variable calls.

Firstly, understanding the template system of Anqi CMS is crucial. It adopts syntax similar to Django's template engine, which means you will mainly use double curly braces{{变量}}To display data, as well as single curly braces and percentages{% 标签 %}To perform logical judgments or call specific functions


To retrieve and display detailed information of a single article

When you visit a specific article page, it usually needs to display its full title, detailed content, concise introduction, and possibly recommended attributes. Anqi CMS provides a named attribute for the article on the current page.archiveThe global variable, you can directly use it to access the various fields of the article.

1. Article Title (Title)

The article title is the soul of the content, you can easily obtain and display it in the detail page:

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

If your template needs to obtain the title of an article with a specified ID, you can usearchiveDetailLabel, and pass in the article ID:

{# 获取ID为10的文章标题 #}
<h2>{% archiveDetail with name="Title" id="10" %}</h2>

2. Detailed content (Content)

The core content of the article is an important part of the detailed information. Anqi CMS'sarchive.ContentThe field contains the full content of the article, which may include HTML tags or Markdown formatted text. To ensure that the HTML content is rendered correctly rather than displayed as plain text, you need to use|safeFilter. If the content is in Markdown format, the Anqicms will automatically convert it to HTML:

<div class="article-content">
    {{archive.Content|safe}}
</div>

If you wish to obtain the detailed content of an article with a specified ID, you can also usearchiveDetailTags:

{# 获取ID为10的文章详细内容,并正确渲染HTML #}
<div class="other-article-content">
    {% archiveDetail articleContent with name="Content" id="10" %}
    {{articleContent|safe}}
</div>

3. Article Summary (Description)

The article summary is a brief overview of the content, usually used for SEO optimization or as a quick preview on the detail page.AnQi CMS will output the profile you fill in the background directly.If you do not manually fill in the summary when publishing an article, the system will automatically extract the first 150 characters of the article content as a summary.

<p class="article-description">
    {{archive.Description}}
</p>

Similarly, get the summary for the specified article ID:

{# 获取ID为10的文章简介 #}
<p class="other-article-description">
    {% archiveDetail with name="Description" id="10" %}
</p>

4. Recommended attribute (Flag)

The AnQi CMS allows you to set various recommended attributes for articles, such as headline, recommendation, slideshow, etc., which are identified by a single letter (for examplehrepresenting the headline,cto represent recommendation). In the article detail page,{{archive.Flag}}These property letters will be directly displayed.

<p class="article-flags">推荐属性:{{archive.Flag}}</p>

These property letters can be used for conditional judgments in templates, for example, to determine if an article is set as a headline:

{% if archive.Flag | contain: "h" %}
    <span class="flag-headline">头条</span>
{% endif %}

Get and display the information in the article list

On category pages, homepages, or other list pages, you may need to display the brief information of multiple articles, including titles, summaries, recommended attributes, as well as article links and thumbnails, etc. At this time,archiveListthe label comes into play.

1. Obtain and iterate through the article list

archiveListThe tag is used to retrieve a list of articles, you can set different filtering conditions as needed, such as category ID, display quantity, sorting method, etc. The retrieved list of articles is an array object, which needs to be accessed throughforto iterate in a loop.

{% archiveList archives with type="list" limit="10" categoryId="1" %}
    {% for item in archives %}
        <div class="article-item">
            {# 这里将显示每篇文章的标题、简介、推荐属性等 #}
        </div>
    {% endfor %}
{% endarchiveList %}

In the above code,type="list"represents getting a normal list,limit="10"limits displaying 10 articles,categoryId="1"then specifies the category ID of the article.archivesis the variable name you defined, representing the list of articles obtained.

2. Display the article title and link in the list

In the list loop,item.TitleUsed to display the title of each article,item.LinkThen provided the access link to the article:

<h3><a href="{{item.Link}}">{{item.Title}}</a></h3>

3. Display the article summary in the list

In the article list, we usually display the summary rather than the detailed content to provide a quick preview:

<p class="item-description">{{item.Description}}</p>

4. Recommended properties in the list

The recommended attribute is usually used in two ways on the list page: one is for filtering articles, and the other is to display a small icon or mark next to the article.

  • Filter the recommended articles in the list:If you only want to display articles set to the "recommended" attribute, you canarchiveListthe tag withflag="c"parameter (assumedcrepresent recommended). Please note that each time the callarchiveListWhen labeling, only one recommended attribute should be used for filtering.

    ”`twig {# Only display the list of articles set to the "recommended" attribute #} {% archiveList recommendedArticles with type=“list” limit=“5” flag=“c” %}

    {% for item in recommendedArticles %}
        <div class="recommended-
    

Related articles

How does AnQiCMS support the switching of multiple templates, as well as how to specify an independent template for a specific page or content type?

## The flexible aspects of AnQiCMS: How to handle multi-template switching and personalized page design A flexible template mechanism is crucial for a content management system to maintain competitiveness and adapt to diverse operational needs.AnQiCMS is an efficient enterprise-level content management system that has demonstrated excellent capabilities in this regard. It not only supports multi-template switching at the whole-site level but also provides detailed features for specifying independent templates for specific pages or content types. This is undoubtedly a powerful tool for websites that need to carry out refined content operations. Firstly

2025-11-07

How to use the `for` loop tag to iterate and display list data in AnQiCMS template?

In AnQiCMS templates, dynamically displaying list data is one of the core operations for building rich website content.Whether it is displaying the latest articles, hot products, category lists, or any custom content collection, the `for` loop tag is your helpful assistant.It allows you to easily traverse data and customize the display of each item according to your needs.Understanding the basics of the `for` loop tag The `for` loop tag is a control structure in the AnQiCMS template engine used for iterating over collection data.

2025-11-07

How to use `if-else` conditional tags to control the display logic of content in AnQiCMS templates?

In AnQiCMS templates, make good use of the `if-else` conditional judgment tag to make content display more intelligent In website content operation, we often need to display different content or styles according to different conditions.For example, when the article list is empty, display 'No content', when an article is in the recommended state, add a 'HOT' mark, or add a special style to the first item in the loop.

2025-11-07

How to use Django template engine syntax to efficiently display various dynamic content in AnQiCMS?

In AnQi CMS, you will find that the built-in Django template engine syntax is an extremely powerful and flexible tool, which can help you efficiently convert backend data into dynamic and lively content on the frontend page.Master this syntax, and you'll not only be able to display basic text and images, but also build complex, interactive dynamic pages, making your website vibrant.The template syntax design of Anqi CMS is very intuitive, it draws on the characteristics of the Django template engine and integrates the concise and efficient Go language.

2025-11-07

How to effectively retrieve and display a thumbnail, cover main image, or a collection of multiple images for an article?

In content operation, captivating images are an indispensable element to attract readers and enhance the quality of articles.AnQiCMS (AnQiCMS) understands this and provides a diverse and flexible set of features, whether it's for the thumbnails of article lists, the cover images on detailed pages, or rich multi-image collections, all can be easily obtained and displayed in the way you expect.How does AnQi CMS handle various images?In AnQi CMS, images are usually divided into several types to meet the display needs of different scenarios: * **Article Thumbnail (Thumb):**

2025-11-07

How to implement the pagination display function of AnQiCMS article list, as well as how to customize the pagination style and logic?

In content operation, the pagination display of the article list is a basic and crucial function, which not only affects the user's browsing experience, but also is closely related to the performance and SEO performance of the website.AnQiCMS as an efficient and customizable content management system provides us with a flexible way to implement and beautify the pagination function of the article list.

2025-11-07

How to get and display the title and link of the previous and next articles on the article detail page?

It is crucial to provide a smooth user experience in the operation of our website.When a visitor finishes reading a rich article, they often want to follow the trail and continue browsing other content in the same category or related topics.In this case, it is particularly important to display the titles and links of the previous and next articles on the article detail page.

2025-11-07

How to configure and display related article lists on the article detail page, and specify relevance rules (such as keywords or manual settings)?

How to make visitors easily find more related content after reading an excellent article on your website, continue to explore your website, which can not only significantly improve user experience, but also is a key strategy to optimize website SEO and reduce bounce rate.AnQiCMS (AnQiCMS) offers powerful and flexible features, allowing you to easily configure and display related article lists on the article detail page and specify relevance rules according to actual needs.Next, we will together learn how to achieve this goal in Anqi CMS.

2025-11-07