How to obtain the title, content, and link of a single page in AnQi CMS?

Calendar 👁️ 61

As an experienced website operations expert, I am well aware of the crucial role of an efficient content management system in the success of a website, especially in terms of flexible content display.AnQiCMS (AnQiCMS) with its powerful template functions and simple Go language architecture, has provided us with great convenience.Today, let's delve into how to easily retrieve the title, content, and links of a single page in AnQiCMS, so that you can better customize and display website information.

Get to know the 'single page' in AnQiCMS

In Anqi CMS, a single page usually refers to those pages with relatively independent content and fixed structure, which are not frequently updated, such as "About Us", "Contact Information", "Terms of Service", or "Privacy Policy" and so on.These pages often carry the basic information and brand story of a website, they play an important role in the website structure, but are different from continuously updated articles or product details.The 'Page Management' feature of AnQi CMS is born for this kind of content, it allows us to customize the content, SEO information, and even independent template files for each single page, such aspage/detail.htmlorpage/{单页面ID}.html.

Get the details of a single page:pageDetailThe clever use of tags

To get the details of a specific single page, AnQi CMS provides a very convenient template tag——pageDetail. This tag is like an intelligent guide, which can accurately extract the single page data you need from the database.

1. Accurately locate the target single page

UsepageDetailWhen labeling, you need to tell it which single page you want. You can do this by using the single page'sID(idparameters)or itsURL alias (tokenparameters)Specify precisely. For example, if you know that the ID of the "About Us" page is 1, you can write it like this: {% pageDetail with id="1" %}. If you are currently on a single page and want to get information about the current page, you do not even need to specifyidortoken,pageDetailThe tag will intelligently identify and obtain data from the current single page.

2. Get the title of a single page

Once a target single page is specified, it is easy to get its title. You just need topageDetailUsed in tagsname="Title"The parameter will directly output the clear title of the single page, used for the H1 tag or navigation link text.

{# 假设获取ID为1的单页面标题 #}
<h1>{% pageDetail with name="Title" id="1" %}</h1>

{# 如果是当前单页面的标题 #}
<title>{% pageDetail with name="Title" %}</title>

3. Extract the rich content of the single page.

The content is the core of a single-page. Usename="Content"Parameters, you can easily extract the main content of the page. This content is usually edited by the backend rich text editor, which may include images, formatted text, etc.

<div class="page-content">
    {% pageDetail pageContent with name="Content" %}
    {{ pageContent|safe }}
</div>

Here are some key points to note:

  • |safeFilter:If your single-page content contains HTML tags (which is very common in rich text editors), in order for the browser to correctly parse these tags and display the formatted effect rather than directly displaying the HTML code, youit mustUsed together|safeFilter. It tells the template engine that this part of the content is safe and does not need to be escaped.
  • renderParameter (for Markdown):If your Anqi CMS has enabled the Markdown editor to write single-page content, and you want the template to automatically render Markdown syntax into HTML, you canname="Content"added afterwardsrender=true.

4. Get the access link of a single page

In addition to the title and content, the link (URL) of a single page is also indispensable. Usename="Link"You can obtain the access path of the single page parameter, you can apply it to the navigation menu, breadcrumbs, or jump buttons within the page.

<a href="{% pageDetail with name="Link" %}">了解更多</a>

5. Other useful information

pageDetailLabels can help you get the summary of a single page (Description),and thumbnail (Thumb) even large images (Logo) and various other information, all of which can be flexibly called throughnameparameters in the template.

Get single page list information:pageListFlexible use of tags

Sometimes, you may need to display multiple single-page lists in a certain area of the website (such as the footer navigation, sidebar), such as 'About Us', 'Terms of Service', and 'Contact Information', etc. At this time,pageListthe tag comes into play.

pageListThe label will return an array of single-page objects, you need toforiterate through these objects. In each iteration, you can access a single single-page object like this,item.Title/item.Link/item.DescriptionIn order to access the properties of each single page.

<nav class="footer-links">
    <ul>
        {% pageList pages %}
        {% for item in pages %}
        {# 判断是否是当前页面,可以添加active样式 #}
        <li {% if item.IsCurrent %}class="active"{% endif %}>
            <a href="{{ item.Link }}">{{ item.Title }}</a>
            {# 如果需要显示简短描述,可以使用item.Description #}
            {# <p>{{ item.Description }}</p> #}
        </li>
        {% endfor %}
        {% endpageList %}
    </ul>
</nav>

This code will iterate over all the created single pages and generate a list item with a title and link for each single page. You can adjust it as neededforContent in the loop, for example, add a thumbnailitem.ThumbOr a brief descriptionitem.Description.

Flexible use of template syntax

The Anqi CMS template system uses a concise syntax similar to Django, making the content call intuitive and efficient.

  • Variable reference:Using double curly braces{{变量名}}To output the value of a variable, for example{{ item.Title }}.
  • the tag to use:Use{% 标签名 参数 %}Call functional tags, for example{% pageDetail %}and{% pageList %}.
  • Filter:Through the pipe|Apply filters to process variables, for example|safeUsed to prevent HTML escaping.

Through proficiencypageDetailandpageListThese powerful template tags allow you to easily retrieve and display the title, content, and link of a single page in Anqi CMS, thereby providing users with a richer and more user-friendly content experience.


Frequently Asked Questions (FAQ)

  1. Why is my single page content displaying HTML code instead of the parsed effect?This is usually because you did not use|safeFilter. The Anqi CMS defaults to escaping all output content for safety.If the content contains HTML tags, be sure to use them in the template like this:{{ pageContent|safe }}.

  2. Can I inpageDetailDo not specify an ID or URL alias in the tag, and directly get the single-page information of the current page?Absolutely, you can. When your template file is used to render a single page (for examplepage/detail.htmlor `page/{single

Related articles

How to implement nested display of multi-level categories (such as product categories) in AnQi CMS?

AnQi CMS, as an enterprise-level content management system, provides high flexibility and powerful functions in content organization and display.For businesses, especially those with complex product lines or websites with a large amount of content, how to achieve clear and logical multi-level classification nesting display is the key to improving user experience and content management efficiency.Today, let's delve into how AnQiCMS elegantly achieves this goal.### The Foundation of AnQiCMS: Flexible Content Model and Classification System In AnQiCMS

2025-11-06

How to display the number of documents under each category on the category list page?

As an experienced website operations expert, I am well aware that how to efficiently display data in content management is crucial for user experience and the overall performance of the website.AnQiCMS (AnQiCMS) with its flexible and powerful template engine, allows us to easily implement these seemingly complex requirements.Today, let's talk about how to clearly display the number of documents under each category on the category list page, which not only makes it easy for visitors to understand but also can improve the website's SEO performance to some extent.

2025-11-06

How to implement custom parameter filtering for document lists in AnQiCMS (such as by region, type)?

## Unlock content potential: How AnQiCMS implements custom parameter filtering of document lists (such as by region, type) As an experienced website operations expert, I am well aware of the importance of an efficient content management system (CMS) in enhancing user experience and content value.AnQiCMS with its flexible and customizable features provides many conveniences in the content operation field.

2025-11-06

How to perform keyword search on the AnQiCMS document list page?

Good, as an experienced website operations expert, I am happy to write a practical guide for you on how to perform keyword search in the AnQiCMS document list page. --- ## Efficient Keyword Search on AnQiCMS Document List Page: A Practical Guide Quickly locating and managing a large number of documents is crucial for improving efficiency in daily content operations.With the continuous enrichment of website content, we often need to accurately retrieve specific articles or products from the vast sea of information.

2025-11-06

How to call the SEO title, keywords, and description of a single page in Anqi CMS?

As an experienced website operations expert, I am well aware of the importance of SEO for website visibility and business growth, and AnQiCMS indeed provides us with powerful and flexible tools in this regard.Today, let's delve into how to accurately call the SEO title, keywords, and description of a single page in AnQiCMS to ensure that each independent page can maximize its potential in search engines.

2025-11-06

How to display the name, description, and link of a single Tag in AnQiCMS?

In a content management system, tags (Tag) are an important tool for organizing content, enhancing user experience, and optimizing search engine rankings.AnQiCMS as an efficient enterprise-level content management system, naturally also provides powerful and flexible tag management functions.As an experienced website operations expert, I know that it is crucial to flexibly apply these functions to the front-end display for the usability and SEO of the website.Today, let's delve into how to accurately display the name, description, and link of a single tag in the AnQiCMS template.

2025-11-06

How to display the list of all Tags associated with an article?

It is crucial to ensure the discoverability of content and the user experience when running a website.A well-written article that can guide readers to explore more related content through appropriate association information will undoubtedly greatly increase users' stay time and the depth of website visits.In the powerful and flexible content management system AnQiCMS, the Tag is the efficient tool to achieve this goal.They not only help you organize and categorize content, but also have a positive impact on search engine optimization (SEO).

2025-11-06

How to call the list of all documents under a specified Tag and perform pagination?

As an experienced website operations expert, I am well aware of how to efficiently organize and present content, which is crucial for the success of a website.Tags act as a flexible content classification method, which not only enhances the browsing experience of users within the site but is also an indispensable part of SEO strategies.AnQiCMS (AnQiCMS) provides us with a powerful content management tool with its simple and efficient architecture and rich features, allowing even massive documents under specified tags to be displayed in an orderly manner and elegantly paginated.

2025-11-06