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, we will delve into a tag that is indispensable for building static content pages -pageDetailand it focuses on itWhat single page of data will be obtained by default?This core issue.

ExplorepageDetail: How does it intelligently retrieve data?

As an experienced website operation expert, I know that every tag behind it contains the wisdom of system design.pageDetailTags, as the name implies, are specifically used for obtainingSingle PageDetails of the data. A single page usually refers to those pages with fixed and independent content, such as "About Us", "Contact Information", "Privacy Policy", and so on.

Then, by default,pageDetailWhich single page's data will the tag actually retrieve? The answer is actually very intuitive and smart:In the absence of any additional parameters specified,pageDetailThe tag automatically retrieves the data of the single page being accessed.

This is like when you are browsing a website and click on the 'About Us' navigation bar, after the page jumps, all the content you see naturally belongs to the 'About Us' single page. Anqi CMS'spageDetailThe label is designed this way. It intelligently identifies the corresponding single page based on the current page's URL path, and loads all related data to be used in the template.

For example, when you visit the URL is你的域名/about-us.html(or any URL configured as a single page) in the template file (such aspage/detail.htmlorpage/about-us.htmlIn it, you do not need to provide any ID or alias, just use the following code to get the title of the single page "About Us":

<div>单页标题:{% pageDetail with name="Title" %}</div>

The system will automatically parse the current page and return the corresponding title.This design greatly simplifies the writing of templates, allowing you to focus more on content presentation rather than cumbersome data association.

Beyond Default: Accurately locate specific single page data

Although the default behavior is very convenient, in some special scenarios, you may need to call data from specific single-page templates on non-single-page detail pages, or dynamically retrieve information from a single page through programming. At this time,pageDetailTags also provide powerful flexibility:

  1. Specify through page ID(idparameter)If you know the unique numeric ID of a single page in the Anqi CMS system, you can useidParameters to specify the data to be retrieved. For example, to get the content of10: single page content

    <div>特定单页内容:{% pageDetail with name="Content" id="10" %}</div>
    
  2. by single page URL alias(tokenparameter)In the Anqi CMS backend, you can set a custom URL for each page, also known as a URL alias or token.This is a user-friendly and easy-to-remember string, such as "about-us", "contact-us", and so on. It is usedtokenThe parameter can be retrieved more readably. For example, to get the link with aliasprivacy-policySingle page link:

    <div>隐私政策链接:{% pageDetail with name="Link" token="privacy-policy" %}</div>
    
  3. Data call in multi-site environment(siteIdparameter):For a security CMS system deployed across multiple sites, if you need to call data from a specific single-page across sites, you can usesiteIdParameters are used to specify the target site. This is usually used in large enterprises or multi-brand management scenarios. For example, to get the site ID of2of a single page title:

    <div>其他站点单页标题:{% pageDetail with name="Title" id="5" siteId="2" %}</div>
    

Application in reality: 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: The unique identifier ID of the single page.
  • Title: The title of the single page.
  • Link: The access link of the single page.
  • Description: The description of the single page, often used for SEO.
  • Content: The main content of a single page. Please note that if the content contains HTML tags, it may be necessary to cooperate to ensure that the browser parses it correctly.|safeFilter usage (such as {{pageContent|safe}}If the single-page content is in Markdown format, you need to addrender=trueparameters to render (such as{% pageDetail pageContent with name="Content" render=true %}{{pageContent|safe}})
  • Logo: The thumbnail or main image of the single page.
  • Thumb: The thumbnail of the single page.
  • Images: A single-page slide group image, usually an array of images, which needs to be traversed in a loop to obtain.

By flexibly combining 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.

Frequently Asked Questions (FAQ)

  1. Question:pageDetailTags andarchiveDetailWhat are the main differences between tags?Answer: They are all used to obtain detailed data, but they are aimed at different content models.pageDetailUsed specifically to retrieve pages created in the "Page Management" sectionSingle pageData (such as "About Us", "Contact Us"), these pages are usually contentually fixed and independent. AndarchiveDetailIt is used to retrieve the content created in the "Content Management".DocumentData, such as articles, products, etc., usually belong to a certain category or model, more in number, and may contain more custom fields.

  2. Ask: If I use on a page that is not a single page (such as an article list page){% pageDetail with name="Title" %}What will happen?Answer: In this case,pageDetailThe label cannot identify which single page the current page's URL corresponds to, it will usually return an empty value or not display any content, depending on how the template handles empty values. To avoid this situation, it is recommended to always use the following method on non-single page pages.idortokenThe parameter explicitly specifies the single page to be retrieved.

  3. Question: How topageDetailDoes the tag correctly display the single page content that I input using the Markdown editor on my backend?Answer: If you enter a single-page content in the Markdown editor in the background andpageDetail with name="Content"obtain it, you need to addrender=trueparameters, and use the output result.|safeA filter to ensure that Markdown is rendered correctly into HTML and displayed safely. For example:{% pageDetail pageContent with name="Content" render=true %}{{pageContent|safe}}.