In the Anqi CMS,archive/listThe interface is the core tool to obtain the document list of the website, which provides a variety of parameters to help us accurately filter and display content. Wherein,childThe parameter may seem simple, but it plays a crucial role in the display of documents and their subcategories, directly affecting the granularity of content presentation.Understand and make good use of this parameter, which can make your website content organization clearer and improve the user experience.
By default, when you go througharchive/listThe interface fetches documents under a certain category,childThe value of the parameter is set totrue.This means that the system will not only return the documents contained in the category itself, but will also automatically include all subcategories and even grandchild categories.For example, if your website has a "News CenterchildThe parameter is set to the defaulttrueThen, all articles under "domestic news" and "international news" will be displayed together.This pattern is very suitable for situations that require a comprehensive display of all related content under a certain theme, allowing users to browse a wider range of information on a single page.
However, in some scenarios, we may need more precise content control. At this time,child=falseThe parameter comes into play. When youchildParameter is explicitly setfalsewhenarchive/listThe behavior of the interface will change significantly.It will strictly limit the range of documents returned, including only those directly assigned to the category you specified and completely excluding any content from its subcategories.
Continue with the "News CentercategoryIdThe ID for the "News Center", and is passed in simultaneouslychild=false. So, the result will only be articles directly published under the "News Center
This refined control capability brings greater flexibility to website operations. When you want a category page to serve as an aggregation entry for all its subcategory content, maintainchild=true(Or not passing this parameter) is the **choice.For example, a "product" category page may need to display all product line documents, regardless of which sub-series they belong to.child=falseIt will be the ideal solution.This helps to create more focused and targeted pages for each category, avoiding information overload, and improving the efficiency of content discovery for users under specific categories.It also applies to creating a "pure" content page for a certain parent category in the navigation menu, ensuring that the content of the page is distinct from that of the subcategories.
In summary, the Anqi CMS'schildParameter inarchive/listThe interface provides powerful control over the display range of document lists.child=true(Default value) Used for broad display, including subcategory content; andchild=falseUsed for deep focus, only showing the direct content of the current category.According to the structure and operation requirements of your website, flexibly using this parameter can effectively optimize the organization of website content and the user browsing experience.
Common Questions (FAQ)
- Q1: Use
child=falseAfter, if I want to display multiple specific categories (including some parent categories and some child categories) of documents at the same time, what should I do?A1: In this case, you need tocategoryIdMultiple category IDs are passed in the parameter, separated by commas. For example,categoryId="1,5,10",系统会返回 ID 为 1、5、10 的分类下的直接文档。Please note that even if you pass the parent category ID,child=falseThe function also only returns the documents directly contained in the parent category, and does not automatically include the documents in its child categories. - Q2:
child=falseDoes the parameter affect?type="related"What is the list of documents in the mode?A2:child=falseThe parameter mainly targets documents passed throughcategoryIdLimit the document scope list query in English.type="related"In mode, the system will search for related documents based on the specified document ID, with the logic more focused on the document itself rather than strict classification levels. Therefore,child=falseparameters.type="related"Pattern usually has no direct impact. - Q3: How do you know if a category has subcategories so you can decide whether to use it?
child=false?A3: You can usecategory/listInterface to get the category list. By checking the returned data for each category'sparent_idfield, you can construct the category hierarchy. If a category'sidappears in other categories,parent_idIn English, it is a parent category with subcategories, at this point you can decide based on your needs whether to use it when querying the parent category.child=false.