In AnQi CMS,archive/listThe interface is the core tool for obtaining the list of website documents, it provides a variety of parameters to help us accurately filter and display content. Among them,childParameters may seem simple, but they play a crucial role in the display of documents in categories and their subcategories, directly affecting the granularity of content presentation.Understand and make good use of this parameter, which can make the organization of your website content clearer and improve the user experience.
By default, when you go througharchive/listWhen the interface retrieves documents under a certain category,childthe value of the parameter is set totrueThis 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 Center' category, it will have two subcategories, 'Domestic News' and 'International News'.When you are requesting the document list of the "News Center", ifchildthe parameter is set to the defaulttrueThen all the articles under 'domestic news' and 'international news' will be displayed together.This pattern is very suitable for situations where it is necessary to fully display 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 point,child=falseParameters come into play. When you willchildThe parameter is explicitly set tofalsethen,archive/listThe behavior of the interface will change significantly. It will strictly limit the range of returned documents, only including those that directly belong to the category you specify, and completely excluding any content from any subcategories.
Continue with the above "News Center" example, if you want to create a dedicated list of "Special Reports" or "Editor's Picks" documents under the "News Center" parent category that do not belong to any subcategory (such as "Domestic News" or "International News"), just set the parameters when calling the interfacecategoryIdFor the ID of the 'News Center' and simultaneously passed inchild=false. The result will only be articles directly published at the "News Center" level, and will not mix in any content from "Domestic News" or "International News."}
This fine-grained 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 **optional. For example, a "product" category page may need to display all product lines' documents, regardless of which sub-series they belong to.On the contrary, if you want a category page to only display its own distinctive content, as an independent thematic area, and not to be diluted by the content of subcategories, then setchild=falseIt will be an ideal solution. This helps create more focused and targeted pages for each category, avoid information overload, and improve the efficiency of content discovery for users in 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 this page is distinct from that of the subcategories.
In summary, of Anqi CMS'schildThe parameter is inarchive/listThe interface provides powerful control over the display range of the document list.child=true(Default value) used for broad display, including sub-category content; andchild=falseIt is used for deep focus, displaying only the direct content of the current category.According to your website content structure and operational needs, flexibly using this parameter can effectively optimize the content organization and user browsing experience of the website.
Frequently Asked Questions (FAQ)
- Q1: Use
child=falseAfter, if I want to display documents from multiple specific categories (including some parent categories and some child categories) at the same time, what should I do?A1: In this case, you need tocategoryIdPass multiple category IDs in the parameter, separated by commas. For example,categoryId="1,5,10"The system will return the direct documents under the categories with ID 1, 5, 10. Please note that even if you pass the parent category ID, due tochild=falseThe function, it will only return the documents directly contained in the parent category, and will not automatically include the documents in its subcategories. - Q2:
child=falseWill the parameter affect?type="related"What is the list of documents under the mode?A2:child=falseThe parameter mainly targets throughcategoryIdTo limit the document scope of the list query. Intype="related"In this mode, the system will search for related documents based on the specified document ID, with its logic focusing more on the document itself rather than strict classification levels. Therefore,child=falseparameter pairtype="related"Patterns usually have 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/listAn interface to get the category list. By checking theparent_idfields in the returned data, you can construct theidhierarchical relationship of categories. If a categoryparent_idIn this case, it is a parent category with subcategories, and you can decide whether to use it when querying the parent category according to your needschild=false.