In the powerful feature matrix of Anqi CMS, providing users with a smooth site navigation experience is crucial,prevArchiveTags are one of the key factors in achieving this goal.It allows us to easily obtain and display the information of the "Previous" document on the current document page, greatly enhancing the continuity of the user's reading and the interactivity of the website.prevArchiveTag returnsprevIn the variable, what properties can you directly call, and how to skillfully use them.

prevArchive标签的核心作用与prevThe essence of the variable

When you use it in the AnQiCMS template{% prevArchive prev %}...{% endprevArchive %}This structure, the system will intelligently recognize the current document and fill it for youprevThis variable.prevAn entity that actually represents a complete document (or "articleTherefore, it can carry a very rich set of properties, far more than just simple titles or links.

We can imagine thatprevThe variable represents the complete data entity of the "previous" document under the current content model, which meets specific sorting rules (usually published time or ID reverse order). This means that everything you canarchiveDetailThe document properties called in the tag, most of which can beprevobtained directly in variables, allowing you to have high freedom and flexibility when building the previous/next navigation.

Next, let's go into detail and sort out these document properties that can be directly called:

1. Basic identification and display information of the document

These are the most fundamental and core attributes that make up the document, which are usually used to directly display to users.

  • Id(Document ID):Each document in the system has a unique numeric identifier. When you need to refer to or further process the previous document,prev.Idit is an indispensable proof of identity.
  • Title(Document Title):This is the H1 title of the previous document, directly calledprev.Titleand it can be displayed on the page.
  • Link(Document link):Access the URL address of the previous document byprev.LinkCan build direct jump links.
  • Keywords(Document keywords):The keywords set in the previous document can beprev.Keywordsobtained for SEO or content association.
  • Description(Document description):Previous document summary, usually an article abstract, callingprev.Descriptionto get it.
  • CategoryId(Document Category ID):The ID of the category to which the previous document belongs, throughprev.CategoryIdyou can know its category affiliation.
  • Views(Document views):Number of times the previous document was read or viewed,prev.ViewsCan be used to display popularity indicators.
  • CommentCount(Document comments):Total number of comments on the previous document,prev.CommentCountCan reflect the interactivity of the content.

Section 2: Content Details and SEO Optimization Properties

To provide richer content previews and support SEO strategies,prevVariables also include detailed content and SEO-related attributes.

  • SeoTitle(Document SEO Title):If the previous document has a separate title set for search engines,prev.SeoTitleThe returned value. This is very useful for providing more precise SEO information in navigation prompts.
  • Content(Document content):This is the complete text content of the previous document. When you need to display a brief preview or require the full content in certain scenarios, you can directly call it.prev.Content. Please note that for security and proper rendering of HTML content, it is usually necessary to combine|safethe use of filters, for example{{ prev.Content|safe }}. If the document content is in Markdown format, you can also use|renderby the filter.
  • ContentTitles(Document content title list):If the previous document content is well structured and contains multiple H tags,prev.ContentTitlesThis will return an array containing these subheadings (and their levels, tags, etc.), which is very useful for generating small content catalogs or quick browsing.
  • CanonicalUrl(Document specification link):For situations where there is duplicate content or URL standardization requirements,prev.CanonicalUrlit will return the normative link of the previous document, which is helpful for search engines to correctly identify the main version.

III. Multi-media Resource Attributes

The image is an important component of content attractiveness.prevVariables also provide various properties related to images.

  • Logo(Document cover first image):It is usually the main thumbnail or the first featured image of the document.prev.LogoIt directly returns its URL.
  • Thumb(Document cover thumbnail):An automatically generated thumbnail based on the content of the document.prev.ThumbReturns its URL, commonly used for small image display in lists and navigation.
  • Images(Document cover image set):If the previous document is a group image type or contains multiple feature images,prev.ImagesIt will return an array containing all image URLs, you can iterate through this array to display a multi-image preview.

4. Timestamp attribute

Time is an important indicator of content freshness,prevThe variable provides the creation and update time of the document.

  • CreatedTime(Document addition time):Timestamp of the first creation of the document.
  • UpdatedTime(Document update time):Timestamp of the last update of the document.

It is noted that these two properties return a 10-digit timestamp. In order to display it as a readable date format on the page, you need to combine with AnQiCMS'sstampToDateLabel formatting, for example:{{ stampToDate(prev.CreatedTime, "2006-01-02") }}.

V. Advanced and Custom Properties

In addition to the above general properties,prevvariables as document objects can also access more underlying or custom data.

  • ModuleId(Document Model ID):ID of the content model of the previous document.
  • ParentId(Parent Document ID):If the previous document is a sub-document (for example, a sub-item in a multi-level product detail),prev.ParentIdit will return the ID of its parent document.
  • UserId(document user ID):发布上一篇文章的用户的ID。
  • Price(价格),Stock(库存),ReadLevel(阅读等级),OriginUrl(原文链接),Flag(Recommended Property):These are the attributes that may exist according to the content model characteristics, such as the properties that may be called in the product model.prev.PriceOr judgment.prev.FlagTo display the 'recommend' or 'headline' tag.
  • Category(Complete classification object): prev.CategoryActually, it will return a complete classification object, you can further accessprev.Category.Title/prev.Category.Linkproperties, to get the detailed information of the classification of the previous document, not just the ID.
  • Document label (viatagListcall):AlthoughprevIt does not directly provideTagsan attribute array, but you can combinetagListthe label, passed initemId=prev.Idto get all related tags of the previous document.
  • Document model settings for other custom field parameters:If your content model defines additional custom fields (such as "author", "source"), these fields will also be included asprevThe direct property of the object exists, you can access it directly as you would a built-in property, for exampleprev.Author. If you need to iterate over all custom parameters, you can combinearchiveParamsthe label, passed inid=prev.Id.

Practical code examples

Understanding these properties, we can build a navigation area that is both beautiful and practical for the 'Previous' section. Here is a common example:

`twig {# Use prevArchive tag to get the data of the previous document #} {% prevArchive prev %}

{#