Managing and displaying single pages in Anqi CMS is one of the fundamental functions for website content construction.A single page is usually used to create pages with relatively fixed structures and independent content, such as 'About Us', 'Contact Information', or 'Service Introduction', etc.If you want to display a list of single pages in a specific area of the website, such as the footer navigation or sidebar, AnQi CMS provides a very intuitive and flexible way to achieve this.
Backend management: easily create and configure single pages
Before displaying the single-page list on the front end, you first need to create and manage these single pages in the Anqi CMS backend. You can do this in the backend'sPage ResourcesFind it under thePage ManagementIn here, you can perform a series of operations:
- Add a new pageCreate a new single-page for your website:
- Edit page content:Customize the page title, SEO information (such as keywords and descriptions), main content (supports rich text editor), and even specify a unique template for the page.
- Set a custom URL: Assign a more friendly, SEO-friendly URL alias for the page.
- Sorting and state managementAdjust the display order of a single page or set it to hidden/show status.
Each single page has its own independent ID, title, content, and link, and this information can be conveniently called when displaying the list on the front end.
UtilizepageListTag to get the list of single-page lists
The Anqi CMS provides a powerful tag system for front-end templates, to retrieve and display the list of all single pages, we need to use one of the core tags -pageListThis tag is specifically used to retrieve all single-page data you create in the background.
pageListThe label usage is very concise and clear. You just need to declare a variable in the template to receive a single-page list, then loop through this variable.forThe basic structure is as follows:
{% pageList pages %}
<ul>
{% for item in pages %}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% endfor %}
</ul>
{% endpageList %}
In the code above:
{% pageList pages %}Declared a namedpagesThe variable will contain all available single-page data.{% for item in pages %}TraversalpagesEach single-page variable will take the current page data and assign it toitemVariable.{{ item.Link }}Will output the access link to the current single-page.{{ item.Title }}It will display the title of the current single page.
In this way, you can easily build a list containing all single page links and titles.
Control and customize the content of the single page list.
In addition to the basic title and link,pageListthe tags in the loop,itemthe variable also provides rich single-page information, which you can selectively display according to your needs:
item.Id: The unique identifier ID of the single page.}item.DescriptionThe brief description of the single page.item.Content: Detailed content of a single page (usually not displayed on the list page, but can be called if needed, remember to use|safeHTML filter).item.Logo: Link to the thumbnail large image of the single page setup.item.Thumb: Link to the thumbnail small image of the single page setup.
Advanced customization: Exclude specific pages.
In some cases, you may want to display all single pages but exclude one or two that are not suitable for the list (such as navigation). You canforAdd a conditional judgment inside the loop to achieve:
{% pageList pages %}
<nav class="site-footer-nav">
<h3>网站地图</h3>
<ul>
{% for item in pages %}
{% if item.Id != 5 %} {# 假设ID为5的“隐私政策”页面不显示在主导航中 #}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>
{% endpageList %}
By{% if item.Id != 5 %}This judgment can flexibly control which single pages appear in the list. Here,5Exclude the actual single-page ID you want to replace.
Consideration in a multi-site environment.
If your Anqi CMS is deployed with multiple sites and you want to get the single page list of a specific site,pageListTags also supportsiteIdparameters, for example{% pageList pages with siteId="2" %}. But for most single-site users, it is usually not necessary to specify this parameter, the system will default to fetching the single-page of the current site.
Comprehensive example: Build a bottom navigation list
Combining the above information, we can create a fully functional bottom single-page navigation example:
<footer class="site-footer">
<div class="container">
<nav class="footer-nav">
<h4>关于我们</h4>
<ul>
{% pageList pages %}
{% for item in pages %}
{# 排除特定ID的页面,并确保页面有内容或描述才显示 #}
{% if item.Id != 10 and (item.Content or item.Description) %}
<li>
<a href="{{ item.Link }}" title="{{ item.Description }}">
{{ item.Title }}
</a>
</li>
{% endif %}
{% endfor %}
{% endpageList %}
</ul>
</nav>
<div class="footer-info">
{# 这里可以添加其他页脚信息,例如版权信息、联系方式等,使用系统标签获取 #}
<p>© {% now "2006" %} {% system with name="SiteName" %} - All rights reserved.</p>
</div>
</div>
</footer>
This example shows how to obtain a single-page list and use simpleifExclude specific pages while utilizingitem.DescriptionAdd title hints to links to enhance user experience. Combine with other system tags (such as{% now %}and{% system %}) to create a more diverse and rich page structure.
Of Security CMSpageListTags make it easy to call and display single-page content, whether it is used to build a navigation menu, a sitemap, or any other scenario that requires listing independent pages, it can provide an efficient and flexible solution.
Frequently Asked Questions (FAQ)
Q1: If I want to retrieve and display a specific single page content instead of the entire list of single pages, which tag should I use?A1: If you only want to display the detailed content of a specific single page, such as all the information on the "About Us" page, you should usepageDetailThe tag allows you to specify the single page to be retrieved by its ID or URL alias, and directly display its title, content, description, and other detailed information.
Q2: Can a single page have categories? Can I set categories for a single page like articles?A2: The single-page design concept in AnQi CMS is used for independent, unclassified content. If you need to manage content categories, such as blog articles, product displays, etc., it is recommended to useContent ManagementbelowDocument ManagementFeature, and create the corresponding "article model" or "product model" and their categories. The single page itself does not have category attributes.
Q3: I created a single-page in the background, but when using it in the foregroundpageListWhy is the label not displayed after that? What could be the reason?A3: There could be several reasons for this:
1. **页面状态**:请检查该单页面在后台是否被设置为“隐藏”或处于“草稿”状态。只有发布并显示状态的页面才能被 `pageList` 标签获取。
2. **模板逻辑**:检查您的 `pageList` 循环内部是否有条件判断(如 `{% if item.Id != X %}`)意外地排除了该页面。
3. **缓存问题**:尝试清除安企CMS后台的缓存,有时缓存会影响内容的即时更新。