In the powerful function system of AnQi CMS, flexibly using various tags is the key to improving efficiency for website operators and template developers. Today, let's delve into a tag that is indispensable for building static content pages.pageDetail,and especially focuses on it in EnglishBy default, which single-page data will be retrieved?This core issue.
Explore the mysterypageDetail:How does it intelligently retrieve data?
As an experienced website operations expert, I know that each tag contains the wisdom of system design.pageDetailTags, as the name implies, are specifically used for acquiringSingle PageDetails of the data. A single page usually refers to those pages with relatively fixed and independent content, such as "About Us
Then, by default,pageDetailWhich single page's data will the tag actually obtain? The answer is actually very intuitive and smart:Without any additional parameters specified,pageDetailThe label will automatically retrieve the data of the single page currently being accessed.
This is like browsing a website when you clicked on the 'About Us' navigation bar, after the page jumps, all the content you see naturally belongs to the single page of 'About Us'. The Anqi CMS'spageDetailThe tag is designed in this way. It will intelligently identify the corresponding single page based on the current page URL path, and load all related data, which can be called in the template.
For example, when the URL you visit is你的域名/about-us.html(or any URL configured as a single page) in the template file (such aspage/detail.htmlorpage/about-us.htmlIn this case, you do not need to provide any ID or alias, and you can directly use the following code to get the title of the "About Us" single-page:
<div>单页标题:{% pageDetail with name="Title" %}</div>
The system will automatically parse the current page and return its corresponding title.This design greatly simplifies the template writing, allowing you to focus more on content presentation rather than cumbersome data association.
Beyond the default: Precisely locate specific single-page data
Although the default behavior is very convenient, in some special scenarios, you may need to call specific page data in templates of non-single-page detail pages, or dynamically obtain information about a single page through programming. At this time,pageDetailTags also provide powerful flexibility:
By using a single-page ID (
idspecified by the parameter):If you know the unique digital ID of a single page in the Safe CMS system, you can useidParameters are used to explicitly specify the data to be retrieved. For example, to retrieve the content of the page with ID10:<div>特定单页内容:{% pageDetail with name="Content" id="10" %}</div>by using the single-page URL alias (
tokenspecified by the parameter):In the AnQi CMS backend, you can set a "custom URLThis is a user-friendly and easy-to-remember string, such as 'about-us', 'contact-us', and so on.tokenParameters can be accessed more readably. For example, to get the single-page link with the alias:privacy-policy:<div>隐私政策链接:{% pageDetail with name="Link" token="privacy-policy" %}</div>data calls in a multi-site environment (
siteId参数):For a CMS system that has deployed multiple sites, if you need to call specific single-page data across sites, you can usesiteIdTo specify the target site. This is usually used in large enterprises or multi-brand management scenarios. For example, to get the site ID of2the title of a single-page page:<div>其他站点单页标题:{% pageDetail with name="Title" id="5" siteId="2" %}</div>
Actual Application: What single-page information can you obtain?
pageDetailThe fields that tags can obtain are very rich, covering all aspects of a single page, including but not limited to:
Id: Unique identifier ID of the single page.Title: Title of the single page.Link: Access link of the single page.Description: Description of the single page, often used for SEO.Content: Single page main content. Please note that if the content contains HTML tags, it may be necessary to cooperate|safeFilter usage (such as{{pageContent|safe}})。If the single-page content is in Markdown format, you also need to addrender=trueparameters to render (such as{% pageDetail pageContent with name="Content" render=true %}{{pageContent|safe}}).Logo: The thumbnail, large image, or main image of the single page.Thumb: The thumbnail of the single page.Images: Single-page slide group image, usually an array of images, which needs to be traversed in a loop to obtain.
Through flexible combination of these parameters and callable fields, you can dynamically present high-quality single-page content at any location on the website with unprecedented convenience.This intelligent data acquisition mechanism not only improves the efficiency of template development, but also lays a solid foundation for the flexible operation of website content and SEO optimization.
Common Questions (FAQ)
Q:
pageDetailTags andarchiveDetailWhat are the main differences between tags?Answer: They are both used to obtain detailed data, but they are aimed at different content models.pageDetail专门用于获取在“页面管理”中创建的Single PageData (such as "About UsarchiveDetailthen used to get the content created in "Content Management"Documentdata, such as articles, products, etc., which usually belong to a certain category or model, are more numerous, and may contain more custom fields.问:If I use it on a page that is not a single-page (for example, an article list page)
{% pageDetail with name="Title" %}What will happen?Answer: In this case,pageDetailThe label usually returns an empty value or does not display any content if it cannot identify which single page the URL corresponds to on the current page, depending on how the template handles empty values. To avoid this situation, it is recommended to always go throughidortoken参数明确指定要获取的单页。Question: How to
pageDetail标签中正确显示我后台用 Markdown 编辑器输入的单页内容?Answer: If you enter single-page content in the Markdown editor in the background andpageDetail with name="Content"to get it, you need to add therender=trueparameter, and use the output result with|safeFilter to ensure Markdown is rendered correctly into HTML and displayed safely. Examples:{% pageDetail pageContent with name="Content" render=true %}{{pageContent|safe}}.