In the powerful feature matrix of Anqi CMS, it is crucial to provide users with a smooth site navigation experience, andprevArchiveThe tag is one of the key factors to achieve this goal. It allows us to easily obtain and display information about the "previous" document on the current document page, greatly enhancing the continuity of the user's reading and the interaction of the website.As a seasoned website operations expert, I am well aware of the importance of transforming technical details into practical strategies. Next, we will delve deeper into the discussion.prevArchivethe tags returned byprevWhat exactly are the document properties that you can directly call from the variable, and how to skillfully use them.
prevArchiveThe core function of the tag andprevThe essence of the variable
When you use AnQiCMS templates{% prevArchive prev %}...{% endprevArchive %}This structure, the system will intelligently identify the current document and fill it for youprevThis variable. ThisprevA variable, actually represents a complete document (or article, product, etc., depending on your content model) object.Therefore, it can carry very rich attributes, far more than just some simple titles or links.
We can combineprevA variable is understood to be the complete data entity of the "previous" document that meets specific sorting rules (usually the reverse order of publication time or ID). This means that any document you canarchiveDetailThe document attribute called in the tag, most of which can beprevobtained directly from the variable, giving you a high degree of freedom and flexibility when building 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 basic and core properties that make up the document, 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 a previous document,prev.Idit is an indispensable proof of identity.Title(Document Title):This is the H1 title of the previous document, directly callprev.Titleand it can be presented on the page.Link(Document link):To access the URL address of the previous document,prev.LinkYou can build a direct jump link.Keywords(Document keywords):The keywords set in the previous document can be accessed throughprev.Keywordsto obtain, for SEO or content association.Description(Document description):The summary of the previous document, which is usually the article abstract, callsprev.Descriptionto get it.CategoryId(Document classification ID):The ID of the classification of the previous document, throughprev.CategoryIdyou can find out its classification attribute.Views(Document views):Number of reads or views of the previous document,prev.ViewsCan be used to display popularity indicators.CommentCount(Document comments):Total number of comments received on the previous document,prev.CommentCountReflects the interactivity of the content.
Section 2: Content Details and SEO Optimization Properties
To provide a richer content preview and support SEO strategies,prevVariables also include detailed content and SEO-related properties.
SeoTitle(Document SEO Title):If the previous document has a separate title set for search engines,prev.SeoTitleThe value will be returned. This is very useful for providing more accurate SEO information in navigation hints.Content(Document content):This is the complete text of the previous document. When you need to display a short preview or require the full content in certain scenarios, you can directly call it.prev.ContentPlease note that for security and correct rendering of HTML content, it is usually necessary to combine|safeFilter usage, for example{{ prev.Content|safe }}If the document content is in Markdown format, you can also use|renderthe filter to convert.ContentTitles(Document content title list):If the previous document content is well-structured, containing multiple H tags,prev.ContentTitlesIt will return an array containing these subheadings (and their levels, tags, etc.), which is very useful for generating a small content catalog or for quick browsing.CanonicalUrl(Documentation specification link):For cases where there is duplicate content or URL standardization requirements,prev.CanonicalUrlit will return the specification link of the previous document, which helps search engines correctly identify the main version.
3. Multimedia resource properties
Images are an important part of content attractiveness,prevVariables also provide various image-related properties.
Logo(Document cover first image):It is usually the main thumbnail or the first featured image of the document,prev.LogoDirectly return its URL.Thumb(Document cover thumbnail):Automatically generated thumbnail based on the content of the system,prev.ThumbReturn its URL, commonly used for small images in lists and navigation.Images(Document cover image set):If the previous document is a set 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 should be noted that these two properties return a 10-digit timestamp, in order to display it in a readable date format on the page, you need to combine with AnQiCMS'sstampToDatetags for formatting, for example:{{ stampToDate(prev.CreatedTime, "2006-01-02") }}.
Five, Advanced and Custom Properties
In addition to the aforementioned general properties,prevThe variable, as a document object, can also access more underlying or custom data.
ModuleId(Document Model ID):The ID of the content model belonging to the previous document.ParentId(Parent document ID):If the previous document is a child document (for example, a sub-item in a multi-level product detail),prev.ParentIdIt will return the ID of the parent document.UserId(Document user ID):The ID of the user who published the previous document.Price(Price),Stock(Stock),ReadLevel(Reading Level),OriginUrl(Original Link),Flag(Recommended Attribute):These are possible properties that may exist based on the content model characteristics, such as possibly invoking in the product modelprev.Price, or judgmentprev.FlagShow the "Recommended" or "Headline" indicator.Category(Complete category object):prev.CategoryIt will return a complete category object, you can further access it.prev.Category.Title/prev.Category.LinkProperties such as obtaining detailed information about the category of the previous document, not just the ID.- Document tags (via)
tagListCall):AlthoughprevDoes not provide directly oneTagsAttribute array, but you can combinetagListto pass the tag,itemId=prev.Idto get all related tags of the previous document. - Other custom field parameters set for the document model:If your content model defines additional custom fields (such as "author","source"), these fields will also be included as
prevThe direct property of the object exists, you can access it like a built-in property, for exampleprev.Author. If you need to iterate over all custom parameters, you can combinearchiveParamsto pass the tag,id=prev.Id.
Practical code examples
Understanding these properties, we can build a navigation area that is both aesthetically pleasing and practical. Here is a common example:
”`twig {# Use prevArchive tag to get the previous document data #} {% prevArchive prev %}
{#