As an experienced CMS website operation personnel in the security industry, I am well aware of the importance of high-quality, well-structured content for website user experience and search engine optimization.The single page is the core of displaying the basic information of the website, such as "About UsIn AnQiCMS, through the powerful template tag system, we can flexibly obtain and display the content of these single pages.
Next, I will elaborate on how to get the list of all single pages and the detailed content of a specific single page in AnQiCMS templates.
Get the list of all single pages
In AnQiCMS template, if you want to display the list of all single pages on the website, we can usepageListLabel. This label helps us easily traverse and output all the single pages created, which is very useful when making a sitemap, footer navigation, or specific information module.
pageListThe usage of labels is simple and clear, it does not require additional parameters by default, and will automatically retrieve all single-page data under the current site. You can define the data retrieved to a variable and thenforLoop through this variable to output the detailed information of each single page one by one. For example, you can define the data aspages:
<ul>
{% pageList pages %}
{% for item in pages %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<p>{{item.Description}}</p>
{% if item.Thumb %}
<img src="{{item.Thumb}}" alt="{{item.Title}}" />
{% endif %}
</li>
{% endfor %}
{% endpageList %}
</ul>
In the above code,itemThe variable represents each single page object in the loop, and you can access itsId(Page ID)、Title(Page Title)、Link(Page Link)、Description(Page Description)、Content(Page Content)、Logo(Thumbnail full image) andThumb(Thumbnail) etc fields.
If you need to exclude some pages based on specific conditions, althoughpageListthe tag itself does not have direct filtering parameters, but can beforCombine within a loop.ifPerform logical judgment for filtering. For example, to exclude a single page with ID 1:
<ul>
{% pageList pages %}
{% for item in pages %}
{% if item.Id != 1 %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<p>{{item.Description}}</p>
</li>
{% endif %}
{% endfor %}
{% endpageList %}
</ul>
Through this method, you can flexibly control which single-page applications need to be displayed in the list. If your website is a multi-site architecture and you want to get the list of single-page applications under a specific site,pageListtag.siteIdParameter to specify the site ID.
Get detailed content of a specific single page
When you need to display the full content of a specific single page, such as the detailed introduction of the "About Us" page,pageDetailLabels are your **choices. This label allows you to accurately retrieve all fields of a single page based on a single page ID or URL alias.
pageDetailThe basic usage of the tag is, you can specify the field name you want to retrieve, or you can get the entire single page object into a variable. For example, to retrieve the title of the current visited single page:
<h1>{% pageDetail with name="Title" %}</h1>
To get the content of a single page with ID 1:
<div>
{% pageDetail pageContent with name="Content" id="1" %}
{{pageContent|safe}}
</div>
It is worth noting that,Contentfields usually need to be combined with output|safeFilter to ensure that HTML content is not escaped. Additionally, if the Markdown editor is enabled in the background,ContentThe field will automatically convert Markdown to HTML. If you need to manually control the conversion behavior, you can userenderparameters, such asrender=trueforce conversion,render=falsedisable conversion.
pageDetailThe supported parameters of the label include:
id: The ID of a single page, used to accurately specify the page information to be retrieved. If not provided, the single page information of the current page will be retrieved by default.token:Single-page URL alias, also used to specify the page to be retrieved.siteId: withpageListSimilar, used to specify the site ID in a multi-site environment.
PasspageDetailThe fields you can access include:Id(Page ID)、Title(Page Title)、Link(Page Link)、Description(Page Description)、Content(Page Content)、Logo(Single page thumbnail large image)、Thumb(Single page thumbnail)as well asImages(Single page slideshow)。
When you need to display multiple images on a single page (such as Banner images or slides).ImagesThe field will return an array. You can iterate over it to output each image one by one:
{% pageDetail pageImages with name="Images" %}
<ul>
{% for item in pageImages %}
<li>
<img src="{{item}}" alt="{% pageDetail with name="Title" %}" />
</li>
{% endfor %}
</ul>
In AnQiCMS, the template file for a single page is usually约定 aspage/detail.html. If you wish to use a separate template for a specific single-page (such as the page with ID 10), you can name itpage/detail-10.html. Furthermore, you can specify a custom template name for a specific page in the single-page management backend, for exampleabout.html, and then store the file in the template directory.page/about.html.
PasspageListandpageDetailThese powerful tags allow you to easily handle the single-page content display of AnQiCMS as a website operator, meeting all kinds of complex website layout and information presentation needs.
Common Questions (FAQ)
How to add a single page to the website navigation?
You can create or edit navigation links in the 'Website Navigation Settings' feature of the AnQiCMS backend.Select 'Category Page Link' under 'Link Type' and then choose the single page you want to add.So, the single page will be displayed at the navigation location you specified.
Can I set a unique template for a specific "About Us" page?
Yes, AnQiCMS supports the use of custom templates for single pages. You can create your custom HTML template files in the directory under thepage/folder, for exampleabout.html. Then, edit the 'About Us' page in the 'Page Management' section of the AnQiCMS backend, and fill in the 'Single Page Template' fieldabout.html.
How should the SEO of a single page be optimized?
Each single page has an independent SEO setting area in the "Page Management" of AnQiCMS backend.You can set 'SEO title', 'keywords', and 'single page description' (corresponding to Description) for each single page.<title>and<meta>Tags are crucial for search engine optimization.At the same time, it is recommended to ensure that the single-page URL alias (custom URL) is descriptive and contains keywords to enhance SEO effectiveness.