How to get and display the title, content, and link of a specific single-page?

Calendar 👁️ 120

As an experienced security CMS website operator, I know that content is the soul of the website, and how to efficiently and accurately present content is a crucial part of our daily work.In AnQi CMS, a single page usually carries the core information of the company introduction, contact information, service description, etc., and its content often needs to be specifically obtained and displayed in various corners of the website.Today, let's delve into how to retrieve and display the title, content, and link of a specific single page in Anqi CMS.

In the Anqi CMS template system, the key to obtaining specific single-page information lies in usingpageDetailThe tag is specifically designed to extract detailed data from a single page, either through its unique ID or its custom URL alias (token).

Get data from a specific single page

To retrieve data for a specific single page, we first need to know the unique identifier for the page, which is usually the page ID or a custom URL alias (token) set in the background.

In the Anqi CMS backend, under 'Page Resources' and 'Page Management', you can find the list of all single pages created.Each single page has a system-assigned ID, and you can also set a custom URL alias for it.For example, a single-page named “About Us” may have an ID of1and its URL alias may be set toabout-us.

Once the ID or URL alias of the target single page is determined, we can use it in the templatepageDetailTag to access its properties. For example, if you want to get the page information with ID1, you can use the tag like this:

{% pageDetail aboutPage with id="1" %}
    {# 在这里可以使用 aboutPage 变量来访问该单页面的各项属性 #}
{% endpageDetail %}

Or, if you know its URL alias isabout-usIt can be used like this:

{% pageDetail aboutPage with token="about-us" %}
    {# 在这里可以使用 aboutPage 变量来访问该单页面的各项属性 #}
{% endpageDetail %}

In the above example,aboutPageWe define the variable name for the single page data we get. Once the data is assigned to this variable, we can access it throughaboutPage.属性名Access the specific fields of the single page in the form

Display the title of the single page

After obtaining the single-page data, the title is displayed very directly. The title of a single page is usually accessed byTitlethe field.

The following is how to display in the templateaboutPageAn example of the single page title represented by the variable:

<h1>{{ aboutPage.Title }}</h1>

This will display the title of the 'About Us' page in the form of a heading on your web page.

Display the content of a single page

The content of a single page is stored inContentWithin a field. Since page content usually contains HTML tags (such as paragraphs, images, links, etc.), in order to ensure that these HTML is rendered correctly by the browser rather than as plain text, we need to use|safefilter.

Additionally, if your single-page content is written using a Markdown editor and the Markdown editor feature is enabled in the background "Content Settings", the system will automatically convert it to HTML. If the Markdown editor is turned off, but the content itself is in Markdown format, you can callContentthe field withrender=trueThe parameter enforces the conversion from Markdown to HTML.

The following is displayedaboutPageAn example of content:

<div class="page-content">
    {{ aboutPage.Content|safe }}
</div>

Or, if you need to enforce the rendering of Markdown content:

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

This will ensure that the content of a single page, including all its formats and elements, is presented correctly on the page.

Display the link to a single page

To obtain and display the link to a single page, we can accessLinkfield. This field will directly provide the complete accessible URL of the single page.

The following is displayedaboutPageHere is an example of the link:

<p>访问我们的页面:<a href="{{ aboutPage.Link }}">{{ aboutPage.Title }}</a></p>

This will generate a hyperlink on the page that points to the single page, with the text content being the title of the page.

Comprehensive Application Example

Combine all the steps above, assuming we need to display the title of a specific single-page in a sidebar and provide an area that jumps to the page when clicked, while displaying some of its content, we can build the template code in this way:

<aside class="sidebar-info">
    {% pageDetail contactPage with token="contact-us" %} {# 假设“联系我们”单页面的token是contact-us #}
        <h2>{{ contactPage.Title }}</h2>
        <p>{{ contactPage.Description }}</p> {# 可以选择显示描述而非完整内容 #}
        <a href="{{ contactPage.Link }}" class="btn-more">了解更多</a>
    {% endpageDetail %}
</aside>

This example shows how to go throughpageDetailTags, flexible to obtain and display key information of a specific single page at any location on the website.Understanding and mastering these tags can greatly enhance your efficiency in content management and template customization on Anqi CMS.


Frequently Asked Questions

What if the single page I need to access has not set a URL alias

If the single page does not have a custom URL alias set, you can still use its unique ID to retrieve information.In the Anqi CMS backend's 'Page Management' list, each single page will display an ID.You canpageDetailUsed in tagsid="单页面ID"in the form to specify the page to be accessed, for example{% pageDetail myPage with id="5" %}.

Why is the HTML content of my single page displayed directly instead of being rendered?

This situation usually occurs because you haven't set up the single page correctly.ContentField usage|safeFilter. Anqi CMS, for security reasons, defaults to escaping all output variables to prevent XSS attacks. IfContentThe field contains valid HTML code, you need to add|safeThe filter informs the system that this content is safe, and can be rendered as HTML, for example{{ myPage.Content|safe }}.

How to set up a custom URL alias for a single page or view its ID in the background?

In the AnQi CMS backend, navigate to 'Page Resources' and then click 'Page Management'.On this page, you can see the list of all single pages created, including their IDs.Click on the 'Edit' button of any single page, after entering the edit page, you can set or modify the URL alias of the single page in the 'Custom URL' field.If not set, the system will automatically generate a default alias based on the page name.

Related articles

How to get the list of all single-page lists of a website?

As an experienced CMS website operation personnel of an enterprise, I know the importance of acquiring and managing website content, especially for single pages carrying core information such as 'About Us', 'Contact Information', or 'Terms of Service'.In AnQi CMS, the system provides an efficient and flexible way to obtain the list of these single pages, so that we can integrate them into website navigation, site map, or other display locations.

2025-11-06

How to retrieve detailed information for a specified category, such as the category name, description, and link?

As an experienced website content expert in AnQiCMS (AnQiCMS) operation, I fully understand the importance of classification information in building website structure and improving user experience.The Anqi CMS, with its intuitive and powerful template tag system, makes it exceptionally easy to obtain and display detailed information about categories.In order to optimize navigation, enrich page content, or improve SEO effect, accurately obtaining the category name, description, and link is an indispensable part of our daily operation.

2025-11-06

How to get the classification list under a specific content model (such as articles, products)?

As an experienced CMS website operation personnel for Anqi, I know the importance of content organization and user experience for the success of the website.Accurately display content categories, not only can help users quickly find the information they are interested in, but also improve the overall SEO performance of the website.Today, we will delve into how to obtain the category list under specific content models (such as articles, products) in AnQiCMS, which is crucial for building clear website navigation, content aggregation modules, and special pages.

2025-11-06

How to correctly generate and display breadcrumb navigation on a page?

As an experienced CMS website operation person in an enterprise, I am very clear about the importance of breadcrumb navigation in improving user experience and website SEO.It not only helps visitors clearly understand their position on the website, but also guides search engines to better understand the website's hierarchical structure.In AnQi CMS, correctly generating and displaying breadcrumb navigation is a fundamental and important content management task.

2025-11-06

How to get the list of the latest published or articles/products under a specified category?

As an experienced AnQiCMS (AnQiCMS) website operator, I am well aware of the importance of content presentation for website user experience and the effectiveness of content marketing.AnQi CMS provides a powerful and flexible template tag system that allows us to easily retrieve and display various types of articles and product lists, whether it is for the latest content updates or for special topic displays under specific categories, all can be achieved through simple configuration.

2025-11-06

How to display the title, content, images, and other detailed information of the current content on an article or product detail page?

As a senior security CMS website operator, I know that the content detail page is a core component of the website, carrying the important mission of displaying key information such as products and articles to users.A well-designed, comprehensive detail page that not only effectively conveys content value but also enhances user experience and SEO performance.Strong and flexible template tags provided by Anqi CMS, allowing us to easily control the display of each item on the page.

2025-11-06

How can you easily obtain and display the link and title of the previous and next articles on the article detail page?

As an experienced website operator familiar with AnQiCMS, I fully understand the importance of effectively guiding users to browse and discover more content in content management.The navigation of the previous/next article on the article detail page not only can significantly improve user experience and prolong the time users stay on the site, but also helps to optimize the internal link structure of the website, which is very beneficial for SEO.I will elaborate in detail on how to conveniently and quickly obtain and display the links and titles of the previous and next articles on the article detail page of AnQiCMS.--- ###

2025-11-06

How to display a list of recommended articles related to the current article on the article detail page?

As an experienced security CMS website operator, I fully understand the importance of high-quality content and refined operation for user retention and website SEO.Display related recommended articles on the article detail page, which can not only effectively extend the user's time on the site and reduce the bounce rate, but also optimize through internal links, improve the overall weight of the website, and is an indispensable part of content operation.Below, I will give a detailed introduction on how to implement this feature in Anqi CMS.

2025-11-06