In website content operation, the organization and retrieval efficiency of content is the key to improving user experience and SEO performance.Especially for sites with diverse content (such as articles, products, events, etc.), how to flexibly filter and display these contents has become a common challenge for operators and template developers.AnQiCMS is a system focused on providing efficient, customizable content management solutions, and its powerful template tag system is the tool to solve this problem.Today, we will delve deeply into a crucial component of the AnQiCMS template tags-archiveFilterslabel'smoduleIdParameters, understand its specific meaning and how to correctly specify it to filter the content of a specific model.

archiveFiltersTags: the foundation of dynamic content filtering.

First, let's understandarchiveFiltersTags themselves. In AnQiCMS,archiveFiltersTags are designed to generate dynamic content filtering conditions. Imagine that your website has a "Real Estate" section, where users may want to search for listings based on "Property Type" (residential, commercial, apartment), "Layout" (one-bedroom, two-bedroom) or "Area".archiveFiltersIt is used to build these filtering options. It is usually applied to the document homepage or category page, along with the document pagination listarchiveListTags used together to provide users with an interactive filtering interface.

When you use it in the template{% archiveFilters filters with ... %}When such a structure is present, AnQiCMS will dynamically generate a series of filter groups and filter values based on the parameters you provide.These filter groups and values will eventually be rendered as clickable links. Each time a link is clicked, the page URL will be appended with the corresponding query parameters, thus achieving precise content filtering.

moduleIdParameter: Lock the core filtering target

Now, let's focus our attention onarchiveFiltersone of the core parameters of the tag -moduleIdWhat does this parameter specifically refer to?

In short,moduleIdThe parameter is used toExplicitly specify the unique identifier (ID) of the "content model" you want to filter the content by..

In AnQiCMS, the 'content model' is a very important concept.It allows you to customize the structure of content based on business requirements. For example, you can define an "article model" to manage blog posts, which may include fields such as "author", "publish date", etc.;You can also define a "product model" to manage product information, which may include fields such as "price", "inventory", "brand", etc.Each content model can have its own unique set of fields, including those custom fields marked as 'filterable' in the background.

When you usearchiveFiltersWhen labeling, AnQiCMS needs to know which type of content model it should generate filtering conditions for.Is it a custom field for 'article' or for 'product'?moduleIdThe parameter plays the role of a 'baton', clearly telling AnQiCMS: "Please generate a filter for the content model with ID X!"

How to specify correctlymoduleId?

Specify correctlymoduleIdIt is the key to ensure that the filter function works normally. The following are some common situations and how to obtainmoduleIdmethods:

  1. Built-in content model:AnQiCMS usually comes with some basic content models, such as 'article model' and 'product model'. By convention, the IDs of these models are usually fixed:

    • Article model:moduleId="1"
    • Product model: moduleId="2"In most cases, if you want to filter articles or products, you can use these two IDs directly.
  2. Custom content model:If you have created a custom content model (such as "property model", "recruitment position model") in the AnQiCMS background, then each custom model will have a unique numeric ID. To find these IDs, you need:

    • Log in to the AnQiCMS backend.
    • Navigate to the 'Content Management' under the 'Content Model' page.
    • Here, you will see the list of all defined content models, each of which will display its corresponding ID. For example, the ID of the 'property model' might be3Then you need to usemoduleId="3".

Once you have determined the ID of the target content model, you can assign its value toarchiveFilterslabel'smoduleIdParameter.

Example code parsing:

Let's take a look at the example code provided in the document and combinemoduleIdfor understanding:

{# 参数筛选代码 #}
<div>
    <div>参数筛选:</div>
    {% archiveFilters filters with moduleId="1" allText="默认" %}
        {% for item in filters %}
        <ul>
            <li>{{item.Name}}: </li>
            {% for val in item.Items %}
            <li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{val.Link}}">{{val.Label}}</a></li>
            {% endfor %}
        </ul>
    {% endfor %}
    {% endarchiveFilters %}
</div>

In this example,moduleId="1"Make it clear to AnQiCMS that this filter shouldTarget the 'Article Model'Generate filter conditions. AnQiCMS will find all custom fields set as filterable under the "Article Model" and generate the correspondingitem(Filter group, such as "Category", "Tag", or custom "Article Type" for the article model), as well as eachitembelowval(Filter values, such as "Technology", "Sports", etc).

Every oneval.Linkwill include a URL pointing to the current page, with the corresponding query parameters, for example?article_type=科技. When the user clicks on this link, the page will reload andarchiveListThe tag automatically detects the URL inarticle_typethe parameters, then only displays articles with the type "Science".

moduleIdContent operation strategy

Utilize correctlymoduleIdParameters can greatly enhance the flexibility of website content operations and user experience:

  • Precise filtering:Provide customized filtering conditions for specific content models, helping users quickly find the information they need, such as displaying product-related filters (color, size) on product pages, rather than article-related filters (author, category).
  • Optimize navigation:Combine URL parameters to implement a SEO-friendly filtered URL structure, enhancing search engines' ability to crawl deep content.
  • Improve conversion:Simplify the user decision path, improve user interaction efficiency within the site, indirectly increase content consumption and conversion rates.

BymoduleIdParameter, you can abstract the complex content filtering logic and implement it in a concise and efficient manner at the template level, giving full play to the powerful content model of AnQiCMS.


Frequently Asked Questions (FAQ)

Q1:moduleIdThe value is the model name, table name, or URL alias? Where should I look up its exact value?

moduleIdThe value is anumeric IDInstead of the model name, table name, or URL alias. You can find the 'Content Model' page under the 'Content Management' menu in the AnQiCMS backend, where each content model will clearly display its corresponding numeric ID.For example, the article model is usually ID 1, the product model is usually ID 2, and the custom model you create will have its own unique numeric ID.

Q2: I have setmoduleIdBut why doesn't the filter show any options?

Even if you specify it correctlymoduleIdIf the content model is underThere is no custom field defined, or the defined custom field has not been set as 'filterable',archiveFiltersThe label will not generate any filter options. Please check if you have added a filterable custom field for this model in the AnQiCMS backend settings.

Q3:archiveFiltersCan the tag be used on any page of the website?

archiveFiltersThe tag is mainly designed forDocument list page or category page. It depends on the current page context to identify the filtered content and usually needs to be associated witharchiveListUse tags together so that after the user clicks the filter option,archiveListthe content filtered by the query parameters in the URL can be reloaded and displayed. In non