Can the `prevArchive` tag retrieve the `Description` (summary) field of the previous document?

Good, as an experienced website operation expert, I am willing to delve deeply into the Anqi CMS for youprevArchiveThe use of tags and answer questions about retrieving the document summary (Description) field.


Unlock AnQi CMSprevArchiveTag: Easily get the summary of the previous document.

In the daily operation of websites, we often need to provide users with a smooth reading experience, guiding them to discover more related content.This is where the 'Previous' and 'Next' navigation in the article detail page plays a crucial role.AnQiCMS (AnQiCMS) is an efficient and flexible content management system that naturally provides us with powerful template tags to easily achieve this function.Today, let's delve intoprevArchiveTag, and pay close attention to whether it can obtain the previous document'sDescription(Abstract) field.

prevArchiveTag: A powerful assistant for content navigation

prevArchiveThe tag in the Anqi CMS template system, as the name implies, is used to obtain information about the "previous" document of the current document.It is usually applied to the document detail page, helping users seamlessly switch to the previous article in the sequence.

In the template design of AnQi CMS,prevArchiveThe use of the tag is very intuitive, its basic form is:

{% prevArchive prev %}
    {# 在这里使用 prev 变量来访问上一篇文档的数据 #}
{% endprevArchive %}

Here, prevIs a custom variable name we use, it will carry all the available data from the previous document. If the current document is already the first in its category, thenprevThe variable will be empty, which requires us to make a judgment in the template to avoid displaying unnecessary links.

Core answer:prevArchiveCan be obtainedDescriptiondo you?

The answer is:Absolutely!

According to the official documentation of Anqi CMS,prevArchiveThe label carriesprevVariables that can access many core fields of the previous document, including the ones we are concerned aboutDescription(Summary) field. This means that you can not only display the title and link of the previous document, but also add a brief summary to it, greatly enhancing the attractiveness and information volume of navigation.

ObtainDescriptionThe method of the field is very simple, just byprev.Descriptionand it is done:

{% prevArchive prev %}
    {% if prev %}
        <div class="previous-article-summary">
            <h3>上一篇:<a href="{{ prev.Link }}">{{ prev.Title }}</a></h3>
            <p>{{ prev.Description }}</p> {# 这里就是获取上一篇文档的摘要 #}
        </div>
    {% else %}
        <p>这是当前分类下的第一篇文档,没有更早的内容了。</p>
    {% endif %}
{% endprevArchive %}

In this way, when users browse to the end of the document, they can not only see the title of "Previous", but also catch a glimpse of the content outline, which has a significant positive effect on stimulating user click interest and improving the discovery rate of website content.

Enhance user experience: Create rich media navigation by combining more fields

It may not be enough to just display the title and summary.prevArchiveLabels also support getting many useful fields, you can combine them cleverly to provide users with a richer and more intuitive navigation experience. BesidesTitleandDescriptionYou can also access the following fields:

  • Id: The unique ID of the document.
  • Link: The access link of the document.
  • Keywords: The keywords of the document.
  • CategoryId: The ID of the category to which the document belongs.
  • Views: Document views.
  • Logo: Document cover first image address.
  • Thumb: Document cover thumbnail address.
  • CreatedTime: Document creation time (timestamp, need to be formatted).
  • UpdatedTime: Document update time (timestamp, formatted).

For example, on your blog or news website, you can create a "Previous" navigation block that includes thumbnails, titles, summaries, and publish times:

{% prevArchive prev %}
    {% if prev %}
        <div class="prev-article-card">
            <div class="prev-article-thumb">
                {% if prev.Thumb %}
                    <a href="{{ prev.Link }}">
                        <img src="{{ prev.Thumb }}" alt="{{ prev.Title }}">
                    </a>
                {% endif %}
            </div>
            <div class="prev-article-content">
                <p class="prev-article-meta">发布于:{{ stampToDate(prev.CreatedTime, "2006年01月02日") }}</p>
                <h4 class="prev-article-title">
                    <a href="{{ prev.Link }}">{{ prev.Title }}</a>
                </h4>
                <p class="prev-article-description">{{ prev.Description|truncatechars:100 }}</p> {# 摘要截断显示,避免过长 #}
            </div>
        </div>
    {% else %}
        <p class="no-prev-article">您正在阅读第一篇文档。</p>
    {% endif %}
{% endprevArchive %}

In the above code, we usedprev.Thumbto display thumbnails,stampToDatea filter to format the time, and utilizetruncatecharsa filter to ensure the summary is not too long, thus maintaining the neat layout of the page.

Conclusion

Of Security CMSprevArchiveTags can easily implement the navigation function of the "Previous" document and, more importantly, they provide rich data interfaces, allowing website operators to deeply explore the value of content, and enhance user experience and the attractiveness of website content through multi-dimensional information such as abstracts and thumbnails.Use these tags flexibly, and your website will significantly improve user retention and in-depth content reading.


Frequently Asked Questions (FAQ)

Q1:prevArchiveandnextArchiveThe tag can be used on which pages and does it require special configuration?A1:prevArchiveandnextArchiveThe tag is mainly designed forDocument detail page. On these pages, the system can automatically identify the current document and find the logical previous or next one.In most cases, they do not require any additional special configuration, as long as the current page is a document detail page and there is a logical 'previous' or 'next' document, the tag can work normally and return data.If the document detail page is not througharchiveDetailThe label rendering or the page URL structure not meeting expectations may cause the label to be unable to correctly obtain the context document.

Q2: If the previous document has not been filled outDescription.{{ prev.Description }}what will be displayed?A2: If the previous document'sDescriptionfield is not filled in the background, then{{ prev.Description }}An empty string will be displayed on the front end, meaning nothing will be output. This usually does not cause the page to error, but for better user experience, you can combine conditional judgment to handle it, for example:

{% if prev.Description %}
    <p>{{ prev.Description }}</p>
{% else %}
    {# 可以在这里显示一段默认文本,或者不显示摘要区域 #}
    <p>点击查看上一篇精彩内容!</p>
{% endif %}

Q3: Besides obtainingTitleandDescription,prevArchiveWhat other fields can be obtained to enrich the display effect of the previous document?A3: BesidesTitleandDescription,prevArchiveThe label also provides many useful fields, such as:

  • Link: Link to the previous document.
  • Thumb: Thumbnail address of the previous document, which can be used to display a visual preview.
  • CreatedTime: The release time of the previous document can be accessed bystampToDateThe filter formats the display and provides time cues.
  • ViewsThe number of views of the previous document, which can be used as an indicator of the popularity of the content. Make good use of these fields, you can design a navigation block for the 'Previous article' that is more attractive and conforms to users' browsing habits.