AnQiCMS provides an efficient way to manage independent pages, such as 'About Us', 'Contact Information', etc.These pages usually have independent titles, content, and images, which need to be presented accurately in the front-end template.pageDetailLabel is the core tool designed by AnQi CMS to achieve this purpose, allowing us to easily extract and display detailed information of a single page from the backend database.
UnderstandpageDetailLabel: The core of single-page content display
in AnQiCMS,pageDetailTags are specifically used to retrieve and display detailed data for a single page.Whether you want to display the title and content of the 'Company Profile' or the detailed text of the 'Terms of Service', it can provide the required data.nameParameters to obtain specific fields of a single page, such as the page title, specific content, or related images. IfnameParameter is omitted, the label will directly output the entire data object of the single page, but this usually needs to be combined with variable assignment to be effectively utilized.
pageDetailThe flexibility of the label is reflected in its ability to retrieve data according to different needs:
idparametersWhen you want to display a single page with a specific ID, you can directly access it by:id="页面ID"to precisely specify. For example,id="1"The data for the single page with ID 1 will be retrieved. If the current page itself is a single page (for example, if the URL path you visit is the address of the single page), this parameter can usually be omitted.pageDetailAutomatically identifies and retrieves information from the current page.tokenparametersIn addition to ID, you can also use the URL alias of a single page (token)to specify the page, which is very useful in some scenarios where it is necessary to locate the page based on a friendly URL.idis similar, for example,token="about-us".siteIdparametersFor scenarios that use the AnQiCMS multi-site management function, if you need to obtain single page data from other sites, you can setsiteId="站点ID"To implement cross-site calls, which is very convenient for building multilingual or multibrand websites with a unified content source.
To retrieve and display core content fields
WithpageDetailLabel, we can conveniently obtain the various components of a single page:
Single page title (
Title): This is the core identifier of the single page. You can use{% pageDetail with name="Title" %}Output the current page title directly in the template. If you want to assign the result to a variable for subsequent use or logical judgment, you can write it like this:{% pageDetail pageTitle with name="Title" %}Then through{{ pageTitle }}Use this title flexibly.Single page content (
Content): The main information of the page is stored in this field. The method of obtaining it is{% pageDetail with name="Content" %}It is worth noting that single-page content often contains rich HTML tags (such as content edited with a rich text editor in the background), in order to ensure that these tags can be correctly parsed and rendered by the browser rather than displayed as raw text.safeFilter to use, for example{{ pageContent|safe }}. Moreover, if your content is being edited in the background using a Markdown editor, you also need to ensure that the Markdown syntax is correctly converted to HTML,pageDetailAdd labelrender=trueParameter, for example{% pageDetail pageContent with name="Content" render=true %}{{ pageContent|safe }}.Single page thumbnail (
Thumb) and large image (Logo): Both are used to display page images.Logousually refers to the main image or large image on a single page,Thumbwhich is its thumbnail version. The ways to get them are,{% pageDetail with name="Logo" %}and{% pageDetail with name="Thumb" %}In the template, you usually use them as,<img>the tag'ssrcattribute values, for example,<img src="{% pageDetail with name="Thumb" %}" alt="页面标题" />This will fill the thumbnail address obtained into the image's.srcproperty.Single-page slideshow group (
Images): Some single pages may need to display a set of images, such as a carousel or gallery.ImagesThe field will return an array of image addresses. Since it is an array, you need to iterate through it using a loop to display these images. For example, you can first assign the image array to a variableforYou can then loop through the image array and display each image.{% pageDetail pageImages with name="Images" %}Then use{% for item in pageImages %}<img src="{{ item }}" alt="页面图片" />{% endfor %}Output each image one by one.Other fields (
Id,Link,Description): In addition to the above core fields,pageDetailThe label can also obtain the unique identifier of the pageIdPage visit linkLinkand brief description of the pageDescription. The methods to obtain these fields are the same asTitle, just replacenamewith the value of the parameter. For example, to get the page link is{% pageDetail with name="Link" %}.
Practice: Build a 'About Us' page
Suppose you are building a single-page 'About Us' and have created the page in the background. In your template file (for examplepage/detail.htmlOr specifically for the "About Us" page customizedpage/about-us.html)You can combine them in this waypageDetailTags to present the full page content:
"`twig {# Page main title #}"