How to retrieve information about a specific model through the content model's URL alias (`token`)?

Calendar 👁️ 77

Use AnQiCMS content model URL alias (token):The wisdom of accurately obtaining information

As an experienced website operations expert, I am well aware of the importance of an efficient and customizable content management system for corporate websites and content operations teams.AnQiCMS with its efficient architecture in Go language and its versatile functions, is gradually becoming a powerful assistant for many operators.In daily content management, we not only strive for the quality presentation of content, but also for the efficient call and management of data.Today, let's delve deeply into a powerful feature in AnQiCMS that can optimize URL structure and achieve precise content acquisition - Content Model URL Alias (token)

In AnQiCMS, the content model is the foundation we build various content types on, whether it's articles, products, events, or single pages, they all rely on the flexible definition of the content model. The closely related URL alias, which is what we usually calltokenIt plays the role of an 'ID card' for the content on the web page.It not only makes our URL address more readable and friendly to search engines, but more importantly, it provides a convenient way to directly locate and obtain specific model information without using an ID.

URL alias (token) Importance: More than just beauty

We all know that a clear and meaningful URL is crucial for SEO and user experience.AnQiCMS was well thought out from the very beginning.When you create articles, categories, single pages, or even the content model itself, the system will automatically generate a pinyin-based URL alias based on the title of the content you enter.Of course, if you are not satisfied with the automatically generated alias, you can always manually modify it to ensure that it reflects the content theme and includes core keywords, thereby better supporting SEO optimization.It is worth noting that in order to avoid link conflicts and unnecessary disturbances, the manually set URL alias must ensure the uniqueness of the entire site.If a duplicate occurs, AnQiCMS will automatically add a random number at the end to ensure its uniqueness.

This custom URL alias mechanism, combined with the pseudo-static rule management function of AnQiCMS, can make your website URL structure more standardized, for example, you can set the document detail page to/{module}-{filename}.htmlor/{catname}/{filename}.html.{filename}It usually corresponds to what we call a URL alias ortoken.

However,tokenIt is far more than just its value. It is not only an aesthetically pleasing part of the URL, but also a powerful parameter in AnQiCMS template tags, allowing us to obtain specific content information in a more intuitive and business-oriented way.

Core mechanism: URL alias (token)How to accurately retrieve information

In AnQiCMS template development, when we want to obtain detailed information about a specific document, category, single page, or model itself, we usually think of using its numeric ID. But when the content ID changes or we want to use a more semantic identifier, tokenParameters came into play. AnQiCMS provides a series of detail tags, all of which support specifying the content to be obtained throughtokenparameters.

These tags include:

  • archiveDetailUsed to obtain detailed information about a specific document (article, product, etc.).
  • categoryDetailUsed to obtain detailed information about a specific category.
  • pageDetailUsed to obtain detailed information about a specific single page.
  • moduleDetailUsed to obtain detailed information about a specific content model.
  • tagDetailUsed to obtain detailed information about a specific tag.

The general calling format of them is roughly as follows:{% XXXDetail 变量名称 with name="字段名称" token="别名字符串" %}. Here,变量名称Optional, if you want to output a specific field directly, you can omit it;name="字段名称"Then it specifies the specific content field you want to get, such asTitle/DescriptionorContent; whereastoken="别名字符串"It is the main character of our day, allowing you to directly lock and extract the corresponding content through that unique URL alias set in the background.

Practical exercise: MastertokenCalling技巧

In order to understand bettertokenActual application, we explore several common scenarios to find out.

Scenario one: Obtain detailed information of a specific article (document)

Imagine that you might need to display a fixed article's title and link in a specific area of a website, such as the 'Recommended Reading' module on the homepage, and the ID of this article may change due to data migration. At this time, if you set a stable URL alias for this article, such asabout-our-companySo it can be passed throughtokencan be easily obtained.

{# 假设“关于我们公司”这篇文章的URL别名是 "about-our-company" #}
<div>
    <h3>关于我们</h3>
    {% archiveDetail companyIntro with name="Description" token="about-our-company" %}
    <p>{{ companyIntro|truncatechars:100 }}</p> {# 截取前100个字符显示简介 #}
    {% archiveDetail companyLink with name="Link" token="about-our-company" %}
    <a href="{{ companyLink }}">了解更多</a>
</div>

Through this code, no matter how the article ID changes, as long as the URL aliasabout-our-companyKeep it unchanged, we can always accurately obtain its introduction and link. This greatly improves the robustness and maintainability of the template code.

Scene two: Get detailed information of a specific category

Sometimes, we may need to display an introduction to a certain product category fixed in the website sidebar or link to a specific solution category in the footer. ThroughtokenWe can easily achieve this goal.

{# 假设有一个名为“热门产品”的分类,其URL别名是 "hot-products" #}
<div class="sidebar-category">
    <h3>{% categoryDetail with name="Title" token="hot-products" %}</h3>
    <p>{% categoryDetail with name="Description" token="hot-products" %}</p>
    {% categoryDetail hotProductLink with name="Link" token="hot-products" %}
    <a href="{{ hotProductLink }}">查看热门产品</a>
</div>

Even if the category ID changes, as long astokenunchanged, the content of the sidebar will also be updated consistently.

Scenario three: Get the content of a specific single page.

The single page is very common in corporate websites, such as 'Contact Us', 'Terms of Service', etc. These pages are often the evergreen trees of the website, with relatively fixed content and links. ThroughtokenIt is the most natural choice to call them.

This is the terms of service page, the URL alias is "terms-of-service"

<nav>
    <ul>
        <li><a href="/">首页</a></li>
        {% pageDetail termsLink with name="Link" token="terms-of-

Related articles

I want to display the Chinese title of the current content model in the template, which field of the `moduleDetail` tag should be used??

As an experienced website operations expert, I know that the flexible use of templates in AnQiCMS (AnQiCMS) is the key to improving website operation efficiency and user experience.When faced with the need to dynamically display content model information, such as the Chinese title of the current content model, choosing the correct label field is particularly important.Today, let's delve deeply into how to accurately display the Chinese title of the current content model in the Anqi CMS template.

2025-11-07

The `moduleDetail` tag's `name` parameter can be used to retrieve which specific fields of the model details?

As an experienced website operations expert, I am well aware that how to efficiently use the built-in tags in a rich-featured content management system like AnQiCMS to drive content display and management is the key to improving operational efficiency.Today, let's delve into the `moduleDetail` tag and its `name` parameter, which can help us accurately obtain the specific fields of the content model, providing strong support for the flexibility and maintainability of the website.

2025-11-07

In AnQi CMS, what parameters does the `moduleDetail` tag support to specify the model to be retrieved?

As an experienced website operations expert, I know that accurately calling and displaying content model details in a flexible and efficient content management system like AnQiCMS is the key to building a functional and user-friendly website.The Anqi CMS, with its powerful custom content model capabilities, allows us to flexibly build data structures according to various business needs (whether it is articles, products, or event pages).Today, let's delve deeper into the process of template development using AnQiCMS, `moduleDetail`

2025-11-07

How to use the `moduleDetail` tag to get the content model ID of the current page?

As an experienced website operations expert, I know that understanding and flexible use of the underlying data structure in a content management system is the key to efficient operations and personalized display.AnQiCMS (AnQiCMS) leverages the efficiency and flexibility of the Go language and its content model to provide us with powerful technical support.Today, let's delve deeply into a seemingly simple yet extremely practical feature: how to use the `moduleDetail` tag to accurately obtain the content model ID of the current page, thereby bringing more possibilities to our content operation and template customization.

2025-11-07

If my AnQi CMS is a multi-site deployment, how to use the `moduleDetail` tag to retrieve the content model data of other sites?

AnQi CMS is an enterprise-level content management system designed specifically for small and medium-sized enterprises, self-media, and multi-site management, and its multi-site management capabilities are undoubtedly one of the core highlights.In daily operations, we often encounter such scenarios: we hope to display certain information of the child site on the main site, or to cross-reference content or data models between different sites.Today, let's delve into a specific and practical scenario - how to use the `moduleDetail` tag to obtain content model data from other sites in a multi-site deployed Aiqi CMS.###

2025-11-07

What is the difference and usage of the `Title` and `Name` fields in the content model in practice?

In the daily operation of AnQiCMS, we often encounter content models and their fields.Among the field names "Title" and "Name", which seem similar, there are completely different responsibilities in practical application.As an experienced website operations expert, I fully understand the importance of understanding these subtle differences for efficient content management, optimizing website structure, and improving user experience.

2025-11-07

How to retrieve the database table name (`TableName`) of the content model in a template for a custom query?

As an experienced website operations expert, I deeply understand the powerful capabilities brought by the flexible content model in AnQiCMS through my practice.Many times, we not only need to display the content itself, but also need to drive deeper page logic or style based on the type of content.Today, let's delve deeply into a seemingly minor but crucial feature: how to obtain the database table name (TableName) of the content model in AnQiCMS templates, thus achieving more refined custom control.--- ###

2025-11-07

Does the `moduleDetail` tag support direct retrieval of custom field values defined in the content model, and if so, how do you call it?

As an experienced website operations expert, I know the importance of a flexible content model and convenient template calls for a modern CMS.AnQiCMS (AnQiCMS) performs well in this aspect, its powerful template tag system makes content presentation flexible and efficient.Today, let's delve deeply into a question that concerns everyone: Does the `moduleDetail` tag support direct retrieval of custom field values defined in the content model?How can it be called if it can? Firstly, let's clarify the division of responsibilities of different tags in the Anqi CMS

2025-11-07