How to retrieve and display the name, description, link, and subordinate category list of a specified category?

Calendar 👁️ 77

In AnQiCMS, effective management and display of website categories are the key to improving user experience and content organization.Whether it is to build a navigation menu, sidebar content, or display the category structure on a specific page, it is a common requirement to flexibly obtain the name, description, link, and subordinate category list of the category.This article will introduce how to use AnQiCMS template tags to easily achieve these functions.


Flexibly obtain and display information of specified categories and subcategory lists

The clear classification of website content is not only convenient for users to browse, but also greatly benefits search engine optimization (SEO).AnQiCMS's powerful template system provides us with intuitive and easy-to-use tags, which can accurately obtain and display the required classification data.To implement obtaining detailed information of a specified category and its subcategory list, we mainly use two core template tags:categoryDetailandcategoryList.

Core Tool:categoryDetailwithcategoryList

categoryDetailTags, as the name implies, are used to obtaina singleSpecify the details of a category. It can help us extract various attributes such as the title, description, link, etc. of a specific category. AndcategoryListThe tag focuses on obtaininga set ofA list of categories, very suitable for listing all subcategories under a parent category, or all top-level categories under a specific content model.Understand and properly apply these tags, it is the key to achieving our goals.

Get detailed information of a specified category

Firstly, we may need to get the basic information of a specific category, such as its name, description, and link. At this point,categoryDetailTags are our ideal choice. It allows us to specify the target category accurately through the unique ID of the category (id) or URL alias (token) to specify the target category precisely.

For example, if you have an ID on your website of5The classification, and if you want to display its title, description, and link on the page, you can write the template code like this:

{# 假设要获取ID为5的分类的详细信息 #}
{% categoryDetail myCategory with id="5" %}
<section class="category-detail-section">
    <h1>分类名称:{{ myCategory.Title }}</h1>
    <p>分类描述:{{ myCategory.Description }}</p>
    <a href="{{ myCategory.Link }}">前往{{ myCategory.Title }}分类页面</a>
</section>

In this code, we will use the ID of5Retrieve the classification information and assign it tomyCategoryvariable. Subsequently, we can easily access and display the name, description, and link of the classification throughmyCategory.Title/myCategory.DescriptionandmyCategory.Linkproperties.categoryDetailTags also provide other rich fields, such asContent(Rich text content of the category),Logo(Category Large Image),Thumb(Category thumbnail) and more, you can flexibly call them as needed.

Display the list of subcategories under the specified category.

After obtaining the detailed information of a specified category, the next step is usually to display all the subcategories under the category. At this point,categoryListthe tag shines brightly on stage.categoryListByparentIdParameters to specify which parent category's subcategories we want to retrieve.

Continuing with the above example, if we want to list the category with ID5Category (i.e.myCategoryThe direct subcategories of ) can be operated in this way:

<section class="sub-categories-list">
    <h2>{{ myCategory.Title }}的子分类</h2>
    <ul>
        {% categoryList subCategories with parentId=myCategory.Id %}
        {% for subItem in subCategories %}
        <li>
            <a href="{{ subItem.Link }}">{{ subItem.Title }}</a>
        </li>
        {% endfor %}
        {% endcategoryList %}
    </ul>
</section>

Here, categoryListThe label's `

Related articles

How to display custom additional field data in the article model to achieve flexible content display?

In Anqi CMS, the flexibility of content is one of its core strengths.We often need to display unique information beyond standard fields such as product SKU codes, publication dates, author information, or specific time and location of events.This personalized data, through the custom additional field feature, can achieve perfect carrying and management.But how to beautifully and flexibly present these meticulously entered custom data on the front end of the website is a focus of many users.This article will guide you to deeply understand the display mechanism of custom fields in Anqi CMS

2025-11-08

How to get and display the list of tags and links associated with the article in the template?

In website operation and content management, article tags (Tag) are key tools for improving content organization, user experience, and search engine optimization (SEO) effects.They can not only help users quickly find relevant content of interest, but also provide clearer content theme information for search engines, thus improving the overall performance of the website.AnqiCMS as an efficient content management system provides intuitive template tags, allowing you to easily obtain and display the list of associated tags and links in the template.

2025-11-08

How to display the cover image, thumbnail, or group image of an article on the article detail page?

In Anqi CMS, adding images to the article detail page is an important link to improve the attractiveness of the content and the reading experience, whether it is the cover main image, thumbnail, or multiple group images.Anqi CMS provides a flexible and intuitive way to manage and display these image resources, allowing you to easily achieve diverse visual presentations. ### The Flexible Use of Article Cover Image and Thumbnail In the article detail page, the cover image (Logo) and thumbnail (Thumb) are the most common image elements.They are usually used to represent the main visual content of an article and are widely used on list pages

2025-11-08

How to retrieve and display the publish time, update time, view count, and comment count of an article?

## Mastering AnQi CMS: A Comprehensive Guide to Article Publishing and Interactive Data Display In website operation, clearly displaying the publication and update time of articles, popularity (page views), and reader feedback (number of comments) can not only effectively improve user experience but also enhance the authority and timeliness of the content.AnQiCMS (AnQiCMS) relies on its flexible template tag system to make the acquisition and display of this key information simple and efficient.This article will explain in detail how to implement these functions in Anqi CMS.### One

2025-11-08

How to display a category-specific Banner image or thumbnail on the category page?

In website operation, designing unique visual elements for different category pages, such as a prominent banner image or a dedicated thumbnail, is an effective means to enhance user experience, strengthen brand image, and promote content conversion.AnQi CMS provides intuitive and powerful functional support to meet this requirement.How does Anqi CMS support category-specific visual content?

2025-11-08

How to get and display the title, content, link, and thumbnail of a specified single page (such as “About Us”)?

In AnQi CMS, the single-page content of a website such as "About UsThese pages not only need to be displayed under independent URLs, but may also need to extract their titles, summaries, links, or thumbnails in other areas of the website (such as the footer, sidebar, or specific modules on the homepage) for display.Anqi CMS provides simple and powerful template tags, allowing you to easily achieve this requirement in website templates.

2025-11-08

How to obtain and display the website's friend link list in the template?

Managing and displaying friendship links in AnQiCMS is a very practical feature, whether it is to increase the external links of the website, improve SEO effects, or to facilitate users to access partner websites, it can play an important role.AnQiCMS provides a simple and efficient way for us to easily obtain and display these links in the template.### Step 1: Background Management and Configuration of Friend Links Before displaying the friend links on the website front-end, we need to add and manage them in the AnQiCMS background system

2025-11-08

How to display the website name, Logo, filing number, and copyright information in AnQiCMS templates?

AnQiCMS provides an intuitive and powerful template system that allows us to flexibly display various core information on the website.Whether it is the name of the website, Logo, filing number, or copyright statement, these are all key elements that constitute the brand image of the website, meet compliance requirements, and enhance user trust.This article will delve into how to call and display this information in the AnQiCMS template, ensuring that your website content is complete and professional.

2025-11-08