How to get the details of the current access category, including the title, link, description, and custom fields?

Calendar 👁️ 79

As an experienced CMS website operator, I am well aware of the importance of high-quality, easily accessible content information for website user experience and search engine optimization.In AnQi CMS, obtaining detailed information about the current visited category is a very basic and frequent requirement in website construction. Whether it is used for page titles, navigation breadcrumbs, or detailed introductions on category pages, it is necessary to accurately call these data.

Our Anqi CMS provides a powerful and flexible template tag system, making it extremely convenient to obtain the title, link, description, and even custom fields of the current visited category.

Get the basic information of the current visited category

In the Anqi CMS template, obtaining the detailed information of the current category mainly depends oncategoryDetailThe tag is powerful because it can automatically identify the category of the current page and extract the required data when you do not need to specify the category ID or alias.This greatly simplifies the complexity of calling category information on the category page or in the document detail page.

For example, on the category list page (such as{模型table}/list.htmlor{模型table}/list-{分类ID}.html) or the document detail page (such as{模型table}/detail.htmlor{模型table}/detail-{文档ID}.html)categoryDetailTags can intelligently obtain the current context classification data.

Title (Title)

To display the title of the current visited classification, we can usecategoryDetaillabel and specifynameparameters for"Title". This title is usually used for the main title of a category page, or as the text of a category link in a document detail page.

<div>当前分类标题:{% categoryDetail with name="Title" %}</div>

Link (Link)

The current category's URL link is crucial for building navigation, breadcrumbs, and optimizing internal link structure. By usingnamethe parameter to"Link",categoryDetailthe tag will return the complete link of the category.

<a href="{% categoryDetail with name="Link" %}">前往此分类页面</a>

Description and Content

Category descriptions are usually a brief text summary, commonly used for page meta descriptions (meta description) or as brief introductions in category lists. AndContentFields can carry more rich rich text content, used for the detailed introduction of the category page.

To get the category description:

<div>分类描述:{% categoryDetail with name="Description" %}</div>

To get the detailed content of the category:

<div>分类详细内容:{% categoryDetail categoryContent with name="Content" %}{{categoryContent|safe}}</div>

Please note that whenContentWhen a field contains HTML or other rich text format, in order to ensure that the content is rendered correctly and not automatically escaped, we usually need to use|safeFilter. If the category content is written using Markdown, Anqi CMS will default to converting it to HTML, and you can alsorender=trueorrender=falseParameters to manually control whether Markdown rendering is performed.

Get Custom Field

The strength of AnQi CMS lies in its flexible content model, allowing operators to add various custom fields to categories.These custom fields greatly expand the expressiveness of classification information, for example, special icons, color codes, additional introduction text, or unique image sets can be added.

To obtain the specific custom field of a category, if you know the name of the field (defined as the 'call field' in the back-end content model), you can access it directly throughnameThe parameter is called. For example, if you define a category namedcustomIcon: custom field

<div>自定义图标:<img src="{% categoryDetail with name="customIcon" %}" alt="分类图标" /></div>

In addition to directly calling specific fields, Anqi CMS also provides a method to display all custom fields through iteration.This is very useful for the scenario where it is needed to dynamically display all the additional properties of a category.Through obtainingname="Extra"We can get an array containing all the custom fields, then useforthem in a loop.

{% categoryDetail extras with name="Extra" %}
{% for field in extras %}
  <div>{{field.Name}}:{{field.Value}}</div>
{% endfor %}

field.NameThe field name (or the parameter name you set in the background) will be displayed, whilefield.Valuethe corresponding value will be displayed.

In addition, the category supports some built-in "custom" image fields, such asLogoUsed for the main image,ThumbUsed for thumbnails, as well asImagesUsed for multiple banner images. The calling method of these fields is similar to that of common custom fields.

<div>分类主图:<img src="{% categoryDetail with name="Logo" %}" alt="{% categoryDetail with name="Title" %}" /></div>

IfImagesThe field contains multiple images and usually requires cooperationforLoop to display:

{% categoryDetail bannerImages with name="Images" %}
{% if bannerImages %}
<div class="category-banners">
  {% for img in bannerImages %}
  <img src="{{img}}" alt="{% categoryDetail with name="Title" %} banner" />
  {% endfor %}
</div>
{% endif %}

By using the above method, the operation personnel of Anqi CMS can easily and flexibly obtain and display all the detailed information of the current access category, thereby creating a rich-content, clear-structured, and well-user-experienced website page.The mastery of these abilities is crucial for improving the effectiveness of content marketing and the overall competitiveness of the website.

Frequently Asked Questions

Q1: How do I get the details of a specific category not currently being accessed?

A: If you need to get the details of a specific category not currently being accessed on the page, you cancategoryDetailthe tag throughidortokenParameters to specify the target category.idParameters accept the numeric ID of the category, whereastokenParameters accept the URL alias of the category. For example, to get the title of the category with ID 10:{% categoryDetail with name="Title" id="10" %}; or by aliasabout-usGet category link:{% categoryDetail with name="Link" token="about-us" %}.

Q2: Does the category content support Markdown format? How to control rendering?

A: Yes, if the Markdown editor is enabled in the content settings of your Anqi CMS backend, and the category content is written in Markdown,categoryDetaillabel'sContentThe field will automatically convert Markdown to HTML. If you need to manually control the rendering process, you can addContentthe field withrenderparameter. Set it torender=trueYou can force Markdown conversion, andrender=falseit will prevent conversion and directly output the original Markdown text. Please make sure to cooperate|safeThe filter to ensure the correct display of HTML content.

Q3: If I need to display a list of categories instead of the details of a single category, which tag should I use?

A: For displaying the category list, you should usecategoryLista tag. This tag allows you to filter by multiple conditions (such asmoduleIdto get the categories under a specified content model,parentIdto get child categories or top-level categories,limitControl the quantity and others) to get multiple categories. It will return an array of category objects, and you need to go throughforLoop through this array, then from each category item (itemRetrieve the title, link, and description information from it. For example, retrieve the top-level category list of the article model: {% categoryList categories with moduleId="1" parentId="0" %}{% for item in categories %}<a href="{{item.Link}}">{{item.Title}}</a>{% endfor %}{% endcategoryList %}.

Related articles

How to use the `categoryList` tag to get and loop through the category list under a specified content model?

As an expert who has been deeply engaged in AnQiCMS content operations for a long time, I know the importance of the category list in website structure and user experience.Make flexible use of the `categoryList` tag, which can help us efficiently organize content, build a clear navigation system, and provide readers with a more accurate content discovery path.Below, I will elaborate on how to use the `categoryList` tag to retrieve and display the category list of a specified content model in a loop.## Use AnQiCMS's `categoryList`

2025-11-06

How to implement dynamic breadcrumb navigation in AnQiCMS template and customize the home page text?

As a senior security CMS website operator, I know that high-quality content and excellent user experience are the foundation of website success.With the powerful functions of AnQiCMS, we can not only efficiently manage content, but also provide users with a smooth and intuitive browsing experience through fine-tuned template customization.Today, let's delve deeply into how to implement dynamic breadcrumb navigation in the AnQiCMS template, and flexibly customize the home page text to enhance the usability and search engine friendliness of the website.

2025-11-06

How to dynamically generate the SEO title, keywords, and description of the current page and support the website name suffix?

As an experienced content management expert who is deeply familiar with AnQiCMS operations, I know the importance of Search Engine Optimization (SEO) for website traffic and user retention.The website's SEO title, keywords, and description (usually abbreviated as TDK) are key factors for search engines to understand page content and for users to decide whether to click.AnQiCMS provides a powerful and flexible mechanism that allows us to dynamically generate these important SEO elements and conveniently integrate the website name as a suffix to enhance brand recognition.

2025-11-06

How to call and display the contact information (such as phone, email, social media) configured in the AnQiCMS template?

As a senior content worker who deeply understands the operation of Anqi CMS, I know the importance of displaying the contact information of the enterprise externally.This not only concerns whether customers can conveniently contact you, but also is the basis for building trust and promoting business cooperation.AnQi CMS provides a直观 and flexible solution for website operators, allowing you to easily manage and display various contact information without writing complex code.

2025-11-06

How to get the list of all single pages or the detailed content of a specific single page in AnQiCMS template?

As a senior security CMS website operator, I am well aware of the importance of high-quality, well-structured content for website user experience and search engine optimization.A single page is the core of a website's basic information display, such as "About Us", "Contact Information", and "Terms of Service", etc.In AnQiCMS, through the powerful template tag system, we can flexibly obtain and display the content of these single pages. I will elaborate in detail on how to obtain the list of all single pages and the detailed content of a specific single page in the AnQiCMS template.###

2025-11-06

How to use the `archiveList` tag to get the article list and support sorting by ID, views, or custom sorting?

As an experienced CMS website operation person, I know that efficient content management is crucial for attracting and retaining users.The template tag system provided by AnQi CMS is its strong point, among which the `archiveList` tag is the core of daily content display.It can help us flexibly extract articles, products, and other content from the database and sort and display them in the way we want.

2025-11-06

How to implement complete pagination functionality for the article list in AnQiCMS template?

As an expert deeply familiar with the operation of AnQiCMS, I know that a smooth, user-friendly website experience is crucial for attracting and retaining users.The pagination feature of a content list is the cornerstone of any content-intensive website, not only optimizing the user's browsing experience, but also an important aspect of search engine optimization.In AnQiCMS, achieving complete pagination for the article list is efficient and flexible through its powerful template tag system.

2025-11-06

How to get the title, link, and thumbnail of the previous and next articles of the current article?

As an experienced website manager familiar with the operation of Anqi CMS, I fully understand the importance of the details of content presentation to user experience and the overall performance of the website.The front and rear navigation function of the article detail page can not only effectively guide users to continue browsing and reduce the bounce rate, but also is an effective means to enhance the relevance between pages and optimize the internal link structure.An enterprise CMS provides a concise and efficient template tag, allowing us to easily achieve this function.--- ### Enhance Content Coherence: Implement Previous and Next Article Navigation in AnQiCMS In Website Content Operation

2025-11-06