Unlock the personalized display potential of content model data in Anqi CMS
How to effectively and flexibly display content in today's content marketing and website operation is the key to success.We all know that the content format of each website is not the same, some need to display articles, some need to display products, and some may need to publish event information, recruitment lists, and so on.If the system cannot support these diverse content structures, it will be very limited in operation.
Auto CMS is created to solve this pain point. It providesFlexible Content ModelFunction, allowing us to customize various content types based on actual business needs.This means we can set fields such as 'author' and 'source' for 'articles', 'price', 'stock', and 'CPU model' for 'products', and even set fields such as 'start time' and 'location' for 'events'.Then, how does the safe CMS support us in displaying these personalized content model data on the website?
The CMS of AnQi uses a template engine syntax similar to Django, making content display intuitive and powerful.It allows us to easily call and present custom content model data through a series of carefully designed template tags, whether it is the detailed display of a single piece of content, the list presentation of multiple contents, or even complex filtering and combination, all can be handled with ease.
Flexible and diverse content detail display
When we need to display detailed information of a single item, such as a product introduction or an in-depth article, the core tag isarchiveDetailThis tag can help us get all the data of the current page or a document with a specified ID.
For example, if you have a product detail page, in addition to the usual title{{archive.Title}}and description{{archive.Description}}There are also many custom fields in the content model, such as “CPU model”, “memory size”, “graphics card type”, etc. These custom fields, we can directly througharchiveDetaillabel combined withnameParameters can be called, for example{% archiveDetail with name="CPU型号" %}Of course, if the field you define for the call in the background content model is in English, such ascpu_model, then you can use it directly in the template{{archive.cpu_model}}Get the corresponding value, convenient and fast.
Better still, if you want to iterate over all custom fields and dynamically display them,archiveParamsLabels come into play. It can retrieve all custom parameters of the current document or a specified ID document, and you can useforLoop them one by one, very suitable for displaying product parameter lists, or for scenarios where the number of custom fields is uncertain. For example:
{% archiveParams params %}
{% for item in params %}
<div>
<span>{{item.Name}}:</span>
<span>{{item.Value}}</span>
</div>
{% endfor %}
{% endarchiveParams %}
For content output by rich text editors, Markdown editors (such as product details, article content), which may contain HTML tags or Markdown syntax, it is necessary to cooperate with|safeor|renderFilter to ensure that the content can be correctly parsed and rendered by the browser, avoiding displaying it as plain text code. For example:{{archiveContent|safe}}or{{archiveContent|render|safe}}.
Presentation of content list with dynamic filtering
On the website, we often need to display content lists, such as the hot articles on the homepage, or all products under a certain category.archiveListTags are the key to implementing these list displays.
This tag allows us to retrieve content based on various conditions, such as throughmoduleIdspecifying the content model (article model ID 1, product model ID 2), throughcategoryIdspecifying the category, throughflag属性(如推荐、幻灯)筛选,或者通过order参数设置排序方式(按最新发布、浏览量等)。在archiveListin the loop, eachitem都代表一条内容,你可以通过{{item.Title}}/{{item.Link}}Access its built-in fields in various ways, of course, including any custom fields you define in the content model, such as{{item.CPU型号}}.
When your content model includes filterable custom fields (such as house models have "type", "area", etc.),archiveFiltersTags can help you build powerful dynamic filtering functions.It will automatically generate filter conditions and corresponding links based on the content model you set.Users can dynamically adjust the display of the list content by clicking on these filter conditions, achieving a highly personalized content exploration experience.This is particularly important for website types such as real estate, recruitment, and product display.archiveFiltersWitharchiveList/paginationTag combination usage, create a comprehensive filtering list page.
Personalized display of auxiliary content
In addition to the document itself, Safe CMS also provides other tags to display personalized data related to the content model:
- Category details:
categoryDetailThe label can obtain information of a specified category, including the fields you customize in category management such as 'Banner image', 'Category content', etc., making the display of the category page no longer monotonous. - Single page details:
pageDetailTags are used to display single page content such as 'About Us', 'Contact Information', etc., and also support calling custom fields or images you set in the single page. - Tag details and list:
tagDetailandtagDataListTags are used to display information on the tag page and the document list under the tag. If the tag itself has a custom description or Logo, it can also be displayed. - Global and auxiliary information:Even if
system/contact/tdkUsed to display tags for website global settings, contact information, and SEO meta information. It also supports calling custom parameters you set in the background, ensuring that every corner of the website reflects your personalized settings.
Template refinement and management
The template design of Anqi CMS is very flexible, allowing us to specify independent template files for different content models, categories, and even specific documents. For example, you can create a template for the "article" model.article/detail.htmlAs a general detail page template, but if a special article needs a unique style, a separate one can be specifiedspecial-article.htmltemplates.
template file is adopted.htmlsuffix, stored in/templatedirectory, and supportsinclude/extends辅助标签,方便我们将页头、页脚、侧边栏等公共部分模块化,大大提高了模板的复用性和维护效率。We can easily handle the complexity of the website content structure and various personalized needs, while maintaining the overall unity and professionalism of the website.
In summary, Anqi CMS provides us with a full-link personalized solution from data definition to front-end display through its powerful content model customization capabilities and flexible template tag system.Whether it is to display the exclusive attributes of a single content or to build a complex filter list, Anqi CMS can help us present technical information in a natural and smooth way, converting it into content that is easy to understand and practical.
Common Questions (FAQ)
1. How to display the custom 'article source' field on the article detail page?You can directly use it in the article detail template.{{archive.文章来源}}Call the value of this custom field, provided that the field name (in English) of the 'Article Source' field in your content model is文章来源. Alternatively, you can also use{% archiveDetail with name="文章来源" %}Label to retrieve and display it.
2. I want the list page to be filtered according to my custom 'Product Color' field, can Anqi CMS do that?Of course you can. You need to set the 'Product Color' as a filterable field in the content model first, and then use it in the list page template.archiveFiltersLabels are used to generate filter links. After users click these links,archiveListlabels will automatically display the corresponding product list data based on the filter parameters in the URL, achieving a dynamic filtering effect.
3. How to display all custom fields of a document at once in a template?You can usearchiveParamsThis can be achieved with a tag. For example,{% archiveParams params %}It will retrieve an array containing all custom fields, you can display them in a singleforiterate over the loopparamsand then through{{item.Name}}Get the field name,{{item.Value}}Get the field value, so that all custom fields and their content can be dynamically displayed.