In AnQi CMS, a single page is a very flexible content form that does not rely on complex classification or model structure. It is often used to publish independent and relatively fixed pages such as 'About Us', 'Contact Information', and 'Service Introduction'.These pages are characterized by independent content, usually requiring only one page to carry their information.pageListTag makes this operation simple and intuitive.
Understand the single-page in AnQi CMS
In the background management interface of AnQi CMS, you can create and manage single pages under 'Page Resources' and 'Page Management'.Each single page can have its own title, content, SEO information, even custom URLs and independent template files.This design allows a single page to be a powerful tool for building the foundation of a website and displaying specific independent information.For example, you can create a single page for "Company Profile", set a concise URL alias for it, and specify a dedicated page template to showcase its unique design.
pageListTags: Get the core list of single pages
To get these single-page lists created in the background and display them in the front-end template, you need to usepageListLabel. The function of this label is to extract all available single-page data, so that you can iterate over and display it in the template.
UsepageListThe basic syntax of the label is very direct:
{% pageList pages %}
{# 在这里遍历 pages 变量,获取每个单页面的信息 #}
{% endpageList %}
In this code block,pagesis a customizable variable name that holds all the data sets of a single page. You need to useforto iterate over this collection, thereby accessing the specific information of each single page.
Traverse and display single page information
In{% pageList pages %}and{% endpageList %}Between tags, you can use it like other list data processing{% for item in pages %}a loop to process each single page one by one.itemA variable represents an independent single-page object in each loop, containing all available fields of the single page.
A single-page objectitemGenerally includes the following common fields, you can call them as needed:
Id: The unique identifier ID of a single page.Title: The title of a single page.Link: The access link of a single page.Description: Brief description of the single page.Content: Detailed content of the single page.Logo: Cover large image of the single page (if set).Thumb: Thumbnail of the single page (if set).
For example, if you want to list all single-page titles and links at the bottom of the website, you can write the template code in this way:
<nav class="footer-nav">
<h3>我们的服务</h3>
<ul>
{% pageList pages %}
{% for item in pages %}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% endfor %}
{% endpageList %}
</ul>
</nav>
This code will generate an unordered list, where each list item is a title of a single page, clicking on it will jump to the corresponding single page.
Advanced Applications and Restrictions
pageListA label has a feature that it is intended to obtainallAvailable single page.This means it does not directly provide parameters for filtering by ID or category.forto use conditional judgment statements inside the loop ({% if %}) to achieve this.
For example, if you want to exclude the 'About Us' page with ID 1, you can modify it like this:
<nav class="footer-nav">
<h3>我们的服务</h3>
<ul>
{% pageList pages %}
{% for item in pages %}
{% if item.Id != 1 %} {# 排除ID为1的单页面 #}
<li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
{% endif %}
{% endfor %}
{% endpageList %}
</ul>
</nav>
For users managing multiple sites,pageListTags also supportsiteIdParameters. If you have created multiple sites and want to call the single-page data of a specific site, you cansiteIdspecify it. For example:{% pageList pages with siteId="2" %}...{% endpageList %}.
In actual use, if the content of a single page contains HTML tags and you want these tags to be parsed normally by the browser instead of being displayed as plain text, remember to outputitem.Contentusing|safeFilter, for example:{{ item.Content|safe }}.
bypageListTags, you can easily build flexible and diverse single-page navigation and content display modules in the Anqi CMS template, greatly enhancing the organization of website content and user experience.
Frequently Asked Questions (FAQ)
pageListCan the tag filter a single page based on specific conditions (such as category, ID)?pageListLabels are used to retrieve the list of all single pages, and they do not directly provide parameters to filter single page IDs or categories. If you need to display specific single pages or exclude certain pages, you can use the tag internally.{% if %}Condition judgment for manual selection. For example,{% if item.Id != 1 %}A single page with ID 1 can be excluded.How to add pagination functionality to the single page list?
pageListThe label itself does not provide built-in pagination functionality, as it is intended to list all single-page items. If your website has many single-page items and requires pagination, you may need to consider categorizing these 'single-page' contents under some 'article model' or 'product model', then using one that supports pagination.archiveListLabel to manage and display. Or, you can implement pagination on the front end using JavaScript.pageListandarchiveListWhat is the difference? When should they be used?pageList专门用于获取和展示在安企CMS后台“页面资源”-“页面管理”中创建的“单页面”内容,这些页面通常用于“关于我们”、“联系方式”等固定内容展示,数量相对较少且内容独立。而archiveListUsed to obtain and display the "Content Management" "Document ManagementpageListDynamic, categorized contentarchiveList.