What parameters does the `{% tagDataList %}` tag support to refine
Hello! As an experienced website operation expert, I am very willing to give you a detailed interpretation of AnQiCMS in{% tagDataList %}The various parameters supported by the label, and how to skillfully use them to build more accurate and attractive content display.
In AnQiCMS, content tags (Tag) are an important way to organize and associate content, which can help users quickly find topics of interest. And{% tagDataList %}Tags are used to retrieve the core tools associated with documents from these rich tags as needed. Understanding and effectively using its parameters will greatly enhance your website's content management capabilities.
Precisely control the content context:{% tagDataList %}Parameter parsing of tags
{% tagDataList %}The core responsibility of the tag is to filter out the document list associated with the specified tag ID. Its basic usage is{% tagDataList archives with tagId="1" %}...{% endtagDataList %}of whicharchivesThis is the custom variable name for the document list we have obtained, whiletagId="1"then specifies the target label.
In order for this label to meet various complex display requirements, AnQiCMS provides multiple flexible parameters, and we will delve into them one by one below:
Core identification parameters:tagId
As the name implies,tagIdThis is the most core parameter of the tag, it is used to specify which tags of documents you want to get. Usually, you will provide a specific tag ID, for exampletagId="5"To retrieve all documents associated with the tag having ID 5.
It is worth noting that if you use this tag on the tag detail page (i.e., the current page is already related to a specific tag) and do not specify it explicitlytagIdthen{% tagDataList %}It will intelligently automatically identify the tag ID of the current page and retrieve the associated document.This brings great convenience to building label topic pages, without the need to hardcode label IDs, the template can automatically adapt.
Content model filtering:moduleId
In an AnQiCMS system that supports multiple content models, content is not limited to articles, but may also include products, events, and other types.moduleIdThe parameter allows you to accurately filter documents under a specific content model.
For example, if you want to display only documents related to the "Go language" tag under, excluding products or event information, you can setmoduleId="1"(Assuming the article model ID is 1). It's like being in a vast library, where not only do you specify the topic, but you also make it clear that you only want to consult the 'books' category, rather than magazines or newspapers.This is crucial for maintaining the professionalism and relevance of content display.
Content sorting strategy:order
The order of content display directly affects user experience and the efficiency of information acquisition.orderParameters give you control over the sorting method of the document list. AnQiCMS provides multiple sorting rules:
id desc: Sort by document ID in descending order, which usually means the latest documents are listed first, suitable for displaying the latest dynamics.views desc: Sort documents by viewing volume in descending order to highlight popular documents and attract more attention.sort descIf you have customized the sorting of the document in the background, use this parameter to display the content according to the priority you set.
By default, if you do not setorderThe system will use the custom sorting rules defined in the background. Based on your operational strategy, you can flexibly choose the sorting method that best suits the current content module, whether it is emphasizing timeliness, popularity, or the importance of manual intervention.
Quantity and pagination control:limitwithtype
The length of the content list and the pagination method directly relate to the page loading speed and user browsing experience.limitandtypeParameters work together to provide strong control.
limitThis parameter is used to set the number of documents you want to display. If you need to get the first 10 documents, just setlimit="10". More advanced usage allows you to also go throughoffsetA pattern to skip a certain number of documents before retrieving, for examplelimit="2,10"Indicates starting from the third document and fetching 10 documents. This is very useful for scenarios such as skipping a few articles that have already been displayed at the top in the 'Recommended Articles' feature.typeThis parameter determines the type of the list.- When set to
type="list"(This is also the default value),{% tagDataList %}It will simply return bylimitthe number of documents specified by the parameter, without involving pagination logic. - When set to
type="page"It will inform the system that this is a document list that requires pagination. At this point, you can work with AnQiCMS's{% pagination %}To build a complete pagination feature. This means that users can browse all matching documents by clicking on "Previous page", "Next page" or page numbers, greatly enhancing the accessibility of a large amount of content.
- When set to
Cross-site content calling:siteId
AnQiCMS supports multi-site management, this powerful feature is also extended to the calling of content tags.siteIdThe parameter allows you to call the label documents under other AnQiCMS sites on the current site.
In most cases, you do not need to set this parameter, the tag will automatically retrieve the data of the current site. But if you are running multiple strongly related sites and want to aggregate and display specific tag content of other sites on one site, just specify the target site'ssiteIdIt can easily realize cross-site content integration and provide technical support for your multi-site operation strategy.
Coordinated with pagination tags:pagination
AlthoughpaginationItself is not{% tagDataList %}The direct parameter, but it is withtype="page"The parameters work closely together to implement the pagination function of the tag document list. When{% tagDataList %}oftypeSet to"page"After that, you can use it in the subsequent part of the template{% pagination pages with show="5" %}to generate page navigation with such tags.pagesThe variable will betagDataListImplicitly passed, which includes the total number of items, total page number, current page number, and links to previous, next, and middle page numbers, etc.show="5"It controls the maximum number of page buttons displayed in the pagination navigation.
This design decouples the content list and pagination logic, making the template structure clearer and easier to maintain. You can useforLoop throughpages.PagesRender specific page link andpages.PrevPage/pages.NextPageUse properties to build prev/next navigation.
Practical operation and strategy advice
Understood{% tagDataList %}The various parameters, next we think about how to apply this knowledge in actual operation:
- Special topic aggregation pageCreate a special topic page for each hot tag, using
tagId(Automatic recognition) andmoduleId(If only articles are displayed), cooperatetype="page"and{% pagination %}To build a rich and easy-to-browse special topic list."), - Sidebar recommendation: In the sidebar of the article detail page, use the current article's tag ID, through
limit="5"andorder="views desc"Display popular articles related to this article to enhance user stay time. - Modular display on the homepageOn the homepage of the website, you can set multiple content modules, each using different
tagId/moduleIdandlimitParameters, for example, "Latest Technology News" (tagId=X, order=id desc, limit=8), "Popular Product Recommendations" (tagId=Y, moduleId=2, order=views desc, limit=4). - SEO optimization: By aggregating pages with tags, combined with precise content titles and descriptions, search engines can better understand the structure of your website content and improve the ranking of specific thematic keywords.
Mastering the flexible application of these parameters will make you more agile in the content operation of AnQiCMS, whether it is to improve user experience, optimize SEO, or find a suitable solution for complex content display requirements.
Frequently Asked Questions (FAQ)
- Ask: Why did I set
tagId,{% tagDataList %}Why doesn't it display any documents?Answer: There are usually several reasons. First, make sure you have provided the following.tagIdIt is correct, and there is indeed a tag corresponding to the ID in the background. Next, check whether the tag under it is really associated with published documents. In addition, if you use it simultaneouslymoduleIdPlease confirm that the associated documents belong to the specified model and that their status is published rather than draft or deleted.