Manage and display single pages in the AnQi CMS is one of the basic functions for website content construction.The single-page is usually used to create pages with relatively fixed structures and independent content, such as "About UsIf you wish to display a list of these single pages in a focused area of the website, such as the footer navigation or sidebar, SafeCMS 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 find them under thePage Resourcesmenu.Page ManagementHere, you can perform a series of operations:

  • Add a new page: Create a brand new single page for your website.
  • Edit page content:Customize the page title, SEO information (such as keywords and description), main content (supports rich text editor), and even specify a unique template for the page.
  • Set custom URL: Assign a more friendly, SEO-friendly URL alias to the page.
  • Sorting and status managementAdjust the display order of a single page, or set it to hidden/display status.

Each single page has its own independent ID, title, content, and link, which can be conveniently called when displaying the list on the front end.

UtilizepageListTag to get the list of single pages

Anq 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 the single-page data you create in the background.

pageListThe label usage is very concise and clear. You only need to declare a variable in the template to receive the single-page list, and 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 above code:

  • {% pageList pages %}Declared a namedpagesThe variable, it will contain all available single-page data.
  • {% for item in pages %}Traversalpageseach single page in the variable, and assign the current page data toitema variable.
  • {{ item.Link }}will output the access link of 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

Besides the basic title and link,pageListtags in the loop,itemVariables also provide rich single-page information, which you can selectively display according to your needs:

  • item.Id: The unique identifier ID of the single page.}
  • item.Description:Single-page brief description.
  • item.Content:Detailed content of a single page (usually not directly displayed on list pages, but can be called if needed, remember to use)|safeFilter parsing HTML).
  • item.Logo:Single page settings thumbnail large image link.
  • item.Thumb:Single page settings thumbnail small image link.

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 can inforAdd a conditional judgment inside the loop:

{% 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 %}

Pass{% if item.Id != 5 %}Such a judgment can flexibly control which single pages appear in the list. Here,5Replace it with the actual single-page ID you want to exclude.

Considerations in a multi-site environment

If your CMS has multiple sites deployed and you want to get a single page list for a specific site,pageListLabels are supportedsiteIdparameters, such as{% pageList pages with siteId="2" %}For most single-site users, it is usually not necessary to specify this parameter, as 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>&copy; {% now "2006" %} {% system with name="SiteName" %} - All rights reserved.</p>
        </div>
    </div>
</footer>

This example shows how to obtain a single-page list and navigate through it simply:ifExclude 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 more diverse and rich page structures.

Anqi CMS'spageListLabels make it easy to call and display single-page content, whether used to build navigation menus, site maps, or any other scenario that requires listing independent pages, providing an efficient and flexible solution.


Common Questions (FAQ)

Q1: If I only want to fetch and display a specific single-page content rather than 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 usepageDetailLabel. This label allows you to specify the single page you want to retrieve precisely by its page 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 Safe CMS is used for independent, uncategorized content. If you need to categorize the content management, such as blog articles, product displays, etc., it is recommended to useContent managementunderDocument ManagementFunction, 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 it is not displayed in the foreground.pageListThe label did not display after the tag, what could be the reason?A3: There could be several reasons:

1.  **页面状态**:请检查该单页面在后台是否被设置为“隐藏”或处于“草稿”状态。只有发布并显示状态的页面才能被 `pageList` 标签获取。
2.  **模板逻辑**:检查您的 `pageList` 循环内部是否有条件判断(如 `{% if item.Id != X %}`)意外地排除了该页面。
3.  **缓存问题**:尝试清除安企CMS后台的缓存,有时缓存会影响内容的即时更新。