`categoryList`is there a difference or**practice**in the way it is called in the mobile template and PC template?

Calendar 👁️ 70

As an experienced website operation expert, I deeply understand the powerful functions and essence of content operation of Anqi CMS, and I am very happy to analyze it in depth for youcategoryListThe tag's calling method in the mobile and PC templates of Anqi CMS, as well as how to utilize its features to achieve efficient and user-friendly content presentation.

On a day when content marketing and user experience are increasingly important, the performance of a website on different devices is crucial.AnQi CMS knows this, as can be seen from its project advantages and core functions, it provides various website modes such as "adaptive, code adaptation, PC+mobile independent sites", aiming to meet the needs of different operation strategies.This explores for uscategoryListThe application in different device templates provides a good foundation.


AnQi CMS template mechanism overview: the foundation of understanding device adaptation.

Further incategoryListBefore making the specific call, we must first have a clear understanding of AnqiCMS's template mechanism. AnqiCMS supports various device adaptation schemes, which directly affects the loading logic of template files:

  1. Responsive Design (Adaptive Mode): In this mode, the PC and mobile ends share the same set of template files.All style and layout adjustments are implemented through CSS media queries and JavaScript to adapt to different screen sizes.This means, yourcategoryListThe tag needs to be called once in a template file, and then controlled on different devices through front-end technology.

  2. Code Adaptation Mode (Adaptive Design):In this mode, AnqiCMS dynamically loads different template files based on the type of device accessing (PC or mobile). The core of it is that you need to create a file named in the template root directory.mobilethe subdirectory. When mobile users visit, the system will prioritize searchingmobilefor the corresponding template file under the directory to render the page.

  3. PC + Mobile independent site modeThis is the most thorough separation scheme, which allows different domain names to be bound for PC and mobile terminals, and to load completely independent template files. Similar to the code adaptation mode, the mobile terminal template is still stored inmobileIn the catalog, but it has a stronger independence, and can be customized more in terms of content and function design.

It is not difficult to see that, whether it is code adaptation or PC+Mobile independent site mode,mobileTable of contentsAll are the key to achieve the independence of mobile template. This means that for these two modes, you can create two different template files for the same page (such as the category list page): one set in the normal template directory for PC, and the other set inmobileUsed for mobile on the directory.


categoryListThe core function of the tag and unified calling method.

categoryListTags are an important tool in AnQi CMS used to obtain category list data. Its design essence lies in providing a unified and powerful data acquisition interface, regardless of the device mode your website is running in, itsThe calling syntax of the tags is completely consistent..

categoryListThe basic usage method is as follows:

{% categoryList categories with moduleId="1" parentId="0" limit="10" %}
    {% for item in categories %}
        <li>
            <a href="{{ item.Link }}">{{ item.Title }}</a>
            <p>{{ item.Description }}</p>
            {% if item.Thumb %}<img src="{{ item.Thumb }}" alt="{{ item.Title }}" />{% endif %}
            {# 更多item字段,如item.Id, item.ParentId, item.HasChildren等 #}
        </li>
    {% endfor %}
{% endcategoryList %}

Here, categoriesIs the custom variable name you use to store the classified list data obtained.withParameters are used to specify the conditions for data retrieval:

  • moduleId: Specify the category list of the content model to be retrieved (for example, article model ID 1, product model ID 2).
  • parentId: Specify the parent category ID. Set to"0"Means to get the top-level category; set to"parent"Means to get the sibling category of the current category; if not set, the default is to get the child category of the current category.
  • limit: Limit the number of categories returned, which can control how many categories are displayed at one time.
  • siteId: In the multi-site management scenario, specify which site to retrieve data from, usually no manual entry is required.

categoryListThe tag itself does not contain any parameters related to the device type (such as PC, mobile end).It is responsible for querying and returning categorized data based on the conditions you provide.It returnsitemFields (such asTitle/Link/Logo/Thumbare also unified, not differing according to the device.


Templates in mobile and PC endcategoryListThe same and different practices called ****

SincecategoryListThe tag's syntax is unified, then where do the differences and **practice manifest when the mobile and PC templates use it?

Core point: unified data layer and tag logic

No matter if you are calling it in the PC template/template/your_template/list.htmlCalling incategoryListor in the mobile template/template/your_template/mobile/list.html} itsTag syntax, parameter passing methods, and accessibility are all consistentitemFields are all consistentThis means that you do not have to learn two different label usages for different devices, which greatly simplifies development and maintenance work.categoryListThe essence lies in providing a unified data acquisition interface, separating data logic from display logic.

The main difference: different presentation layers and layout strategies

The core of the difference lies inThe Anqi CMS will load different template files according to the device type. When the system detects a mobile device visit, it will prioritize to gomobileFind the corresponding template file under the directory to render the page. This allows you to design different layouts and styles according to thecategoryListdata obtained, with different layouts and styles:

  1. The layout and style have been completely rebuilt: On the PC template, you may use complex grid layouts, large image displays, and rich interactive effects to display categories.In the mobile template, you can simplify it to a single-column list, small images, or even plain text links to ensure clarity and quick loading on small screens.For example, the PC side may display categories.LogoLarge image, while the mobile end only displaysThumbThumbnail or only displayTitle.

  2. Fine control of data volume: AlthoughcategoryListThe device itself does not have any parameters, but since it is a different template file, you can set a smaller value for the parameters in the mobile template.limitFor example, set a smaller value for the parameters:

    • PC template (list.html):{% categoryList categories with moduleId="1" parentId="0" limit="20" %}
    • Mobile template (mobile/list.html):{% categoryList categories with moduleId="1" parentId="0" limit="8" %}So, mobile users can see a more streamlined category list, reducing scrolling.
  3. Differentiation of interaction methods: Mobile templates can be optimized for touchscreen operationscategoryListInteractive, for example, supporting sliding, accordion folding, etc., while the PC end may focus more on mouse hover effects.

**Practical suggestions:

  • Unified data source, diverse displayThis is the core idea of using Anqi CMS independent template.categoryListResponsible for providing data, while the template is responsible for presenting according to the characteristics of the device.
  • Maintain consistent core logic.In PC and mobile templates, try to letcategoryListofmoduleId

Related articles

How to customize the `categoryList` in multi-level nesting, the character style and content before the child category `Spacer`?

As an experienced website operations expert, I am well aware of the importance of website navigation and content classification for user experience and SEO.AnQiCMS (AnQiCMS) with its flexible template engine and rich tag system provides us with powerful content display capabilities.Today, let's delve deeply into a detail that is common in multi-level category displays but often overlooked - how to customize the `Spacer` character style and content before the subcategory in the `categoryList` tag.### Perceiving the Beauty of Hierarchical Layers

2025-11-06

Does the `categoryList` tag output the `item.Content` field support automatic conversion of Markdown formatted content?

As an expert in website operations for many years, I deeply understand the intricacies of content presentation, especially in content management systems, how to flexibly and efficiently handle different formats of content is the key to improving website user experience and operational efficiency.Today, let's discuss a common question about AnQiCMS (AnQiCMS) content display: 'Does the `categoryList` tag output the `item.Content` field support automatic conversion of Markdown format content?'}]

2025-11-06

Can it be implemented to create a category list based on alphabetical index through `categoryList`?

As an expert who deeply understands website operation and is well-versed in all the functions of AnQiCMS, I often encounter various inquiries about the form of content presentation.TodayOn many content-rich websites, especially those that contain a large number of product categories, person entries, or professional terminology, there is a classified index list arranged in alphabetical order

2025-11-06

What is the corresponding relationship between the `categoryList` tag and the classification related fields in the background `content model` settings?

As an experienced website operations expert, in my practice with AnQiCMS, I deeply understand that its flexible and powerful content management capabilities are the cornerstone of website success.Today, let's delve into a seemingly simple but highly flexible core mechanism: the `categoryList` tag and the correspondence relationship of classification-related fields in the background `content model` settings.Understanding this can help you control the presentation of website content more finely, realizing truly customized operation strategies.

2025-11-06

How to ensure that the `categoryList` generates absolute path links for external reference or SEO?

As an expert who deeply understands website operation, I know the importance of the standardization of website links for search engine optimization (SEO) and user experience.In such an efficient and powerful content management system as AnqiCMS, ensure that category links are presented in absolute path form, which not only enhances the visibility of the website in search engines but also facilitates the citation and sharing of content on external platforms.Today, let's delve into how to elegantly achieve this goal in AnqiCMS.### The Foundation for Optimizing SEO and External References: Understanding the Value of Absolute Paths Imagine that

2025-11-06

In AnQiCMS, `categoryList` and `pageList` coexist without any issues, a practical template for intelligent operation

As an experienced website operations expert, I know that the flexible use of template tags in a content management system is the key to building an efficient and multifunctional website.Many AnQiCMS (AnQiCMS) users, especially those friends who are new to template development, may have a question: Will there be a conflict if tags with different functions like `categoryList` and `pageList` are used simultaneously on the same page??

2025-11-06

Does the `categoryList` tag support fuzzy search or filtering by category name (without going through URL parameters)?

As an experienced website operation expert, with a deep understanding of the various functions and content operation strategies of AnQiCMS, I am more than happy to analyze whether the `categoryList` tag in AnQiCMS supports fuzzy search or filtering based on category names, an important issue.In the Anqi CMS template system, the `categoryList` tag is the core tool for developers and content operators to obtain and display the website category list.It helps us build clear website navigation and content structure with its concise and efficient characteristics. However,

2025-11-06

How to extend the additional features of the `categoryList` tag without modifying the AnQiCMS core code?

As an experienced website operations expert, I fully understand how to skillfully utilize the existing functions of the CMS system to expand without touching the core code, which is crucial for maintaining system stability and reducing upgrade costs.AnQiCMS (AnQiCMS) offers us a powerful tool for deep customization at the content operation level with its flexible template engine and rich tag system, among which the `categoryList` tag is often a point where we need to expand the function.In Anqi CMS

2025-11-06