How to use the `userGroupDetail` tag to parse and utilize the user group's `Setting` key-value pair data?

Calendar 👁️ 60

AnQiCMS (AnQiCMS) provides a powerful and flexible user group management feature, which not only helps us to finely divide user permissions, but also enables content monetization and member services through the VIP system. Behind these features, ...userGroupDetailTags play an important role, they can help us obtain detailed information about user groups, and the most flexible and valuable part in terms of application is the user group'sSettingkey-value data.

Today, let's talk about how to cleverly useuserGroupDetailtags, parse, and fully utilize the user group'sSettingkey-value pairs to bring more possibilities to our website.

Get to knowuserGroupDetailTag

userGroupDetailThe main function of the tag is to obtain detailed information about a specific user group.It is like a query tool, by entering the user group ID or level, you can return all the preset data of this user group.

The label's usage is very intuitive:{% userGroupDetail 变量名称 with name="字段名称" id="1" %}. Among them,idThe parameter is used to specify the unique identifier for the user group, or you can also uselevelParameters to specify the level of the user group. These two parameters are usually chosen one at a time to accurately locate the user group you want to obtain information about.

userGroupDetailCan provide various information about the user group, such as the user group's.Id/Title(Name),Description(Introduction),Level(Level),Price(Purchase price) as wellFavorablePriceDiscount prices, etc. And the focus of what we are concerned about today is one namedSettingfield.

In-depth analysisSettingkey-value data

SettingThe field is a very powerful custom configuration item in the user group details.It allows us to store a series of custom key-value pairs of data in the background for each user group, which can be any information that needs to be flexibly configured, such as exclusive privileges, functional limitations, display styles, and so on.For example, you can set a 'special discount' or 'download limit' for the VIP user group.

When we are in the background user group management interface, we add key-value pairs for a user group,Settingsuch as keys forvipDiscountwith a value of0.8; key isexclusiveServicewith a value oftrue), these pieces of information are stored in the user group.Settingin the field.

How to obtainSettingdata

To obtainSettingData, we first need to pass throughuserGroupDetailLabels to obtain the overall information of the user group, and then access through dot syntax (.) to accessSettingfield.

Assuming we want to retrieve all the information of the user group with ID 1 and assign it togroupInfothe variable, we can write it like this:

{% userGroupDetail groupInfo with id="1" %}
  {# 现在 groupInfo 变量包含了用户组的所有信息 #}
  <div>用户组名称:{{ groupInfo.Title }}</div>
  <div>用户组等级:{{ groupInfo.Level }}</div>
  {# 获取 Setting 键值对数据 #}
  {% set groupSetting = groupInfo.Setting %}
  {# 此时,groupSetting 变量就包含了用户组的所有自定义设置 #}
{% enduserGroupDetail %}

In this code, we assigned the obtained user group details togroupInfovariable. Then, by{% set groupSetting = groupInfo.Setting %}This line of code, we putSettingAll the key-value pairs in the field extracted togroupSettingThis new variable, for ease of use later.

How to utilizeSettingkey-value pair

Once we getgroupSettinga variable, it usually exists in an accessible object form, and we can directly access the predefined keys through dot notation.

For example, if you have configured the following key-value pairs in a user group in the background,Settingthe following key-value pairs:

  • Key:vipDiscountValue:0.9(indicating a 10% discount)
  • Key:exclusiveIconValue:/static/images/vip_icon.pngRepresents the path of the exclusive VIP icon
  • Key:maxDownloadsValue:100Represents the maximum daily download amount

Then in the template, you can access these data directly like this:

{% userGroupDetail groupInfo with id="1" %}
  {% set groupSetting = groupInfo.Setting %}
  <h3>{{ groupInfo.Title }} 专属特权:</h3>
  <ul>
    <li>专属折扣:{{ groupSetting.vipDiscount * 100 }}%</li>
    <li>
      专属图标:
      {% if groupSetting.exclusiveIcon %}
        <img src="{{ groupSetting.exclusiveIcon }}" alt="{{ groupInfo.Title }}图标" style="width: 30px; height: 30px;" />
      {% else %}
        无专属图标
      {% endif %}
    </li>
    <li>每日最大下载量:{{ groupSetting.maxDownloads }} 次</li>
    <li>是否拥有专属客服:
      {% if groupSetting.hasExclusiveSupport == true %}
        是
      {% else %}
        否
      {% endif %}
    </li>
  </ul>
{% enduserGroupDetail %}

In this way, we can easily display the user group privileges configured on the backend on the frontend page. Whether it's showing different badges, discount information, or providing different feature entry points based on user groups,SettingPairing provides great flexibility.

Practical scenarios and value

UtilizeuserGroupDetailTags andSettingPairing data, you can implement many practical website functions:

  1. Personalized member benefits display: On the user center page, dynamically display exclusive discounts, bonus points, and advanced feature access rights based on the user's membership level.
  2. Dynamic feature switchSome features (such as AI writing, advanced filtering) can be configured inSetting, and only users from specific user groups can see or use them.
  3. Multilingual content or style customizationConfigure different welcome messages, image paths, or CSS classes for user groups of different languages to achieve a more refined multilingual site experience.
  4. Refine content access permissions: Combine the user's current group to obtain itsSettingcontent access permission configuration to determine whether to display or hide certain sensitive content.

SettingThe flexible application of key-value pairs makes the user group function of Anqi CMS no longer just simple permission control, but also becomes a powerful engine that drives personalized services and content monetization on the website.

Summary

userGroupDetailtags and theirSettingThe key-value feature has brought great convenience and extensibility to Anqi CMS users.By calling the simple template tags, we can easily obtain and utilize the various custom data configured by the background for user groups, thus realizing richer, smarter website content display and user experience.Mastery of this feature will add infinite possibilities to your website's operational strategy.

Frequently Asked Questions (FAQ)

  1. SettingWhat types of data can be stored in the field? SettingFields are typically stored as string key-value pairs, but when parsed by a template engine, it attempts to convert them into accessible structures (such as Go

Related articles

How to display the purchase price and discount price of the user group on the `userGroupDetail` tag on the front-end?

Display user group purchase price and discount price on AnQiCMS front-end AnQiCMS's strength lies in its flexible user group management function for small and medium-sized enterprises and content operators, making it easy to implement paid content and membership services.When we set exclusive purchase prices and discount prices for different user groups, how can we display this information intuitively on the website front end, so that users can see it at a glance and thus better guide their purchase decisions?`userGroupDetail` tag is the key tool to solve this problem.

2025-11-07

How to obtain the name and description of a specified user group by user group ID in AnQi CMS template?

In AnQi CMS template development, we often need to display different content based on specific conditions, or extract specific information from the system.User group management is a core function of Anqi CMS, which allows us to classify and control website users in a fine-grained manner.When you need to obtain the name and introduction based on the user group ID, Anqi CMS provides a concise and efficient template tag to achieve this goal.

2025-11-07

Can the `userGroupDetail` tag accurately determine through the `Level` (level) of the user group

AnQiCMS where the `userGroupDetail` tag accurately locates user levels: the key to personalized content operation In today's increasingly refined era of content marketing, providing personalized content experiences for different user groups has become an important strategy to enhance user satisfaction and conversion rates.AnQiCMS is a powerful enterprise-level content management system that provides many conveniences in this regard.Among these, the user group management feature is the core of achieving this goal. Today

2025-11-07

How does the `userGroupDetail` tag display the `Title` (name) and `Description` (description) of the user group?

AnQiCMS (AnQiCMS) leverages its flexible and powerful template tag system to provide great convenience to website operators.In daily user management and content operations, we often need to display different information based on the user's identity or permissions.The User Group (User Group) serves as a core permission management mechanism in AnQiCMS. Its name and description are crucial for clearly communicating the rights, services, or identity positioning to the users.

2025-11-07

In the template, what is the difference between the `id` and `level` parameters of the `userGroupDetail` tag, and how do I choose to use them?

In AnQi CMS template development, the `userGroupDetail` tag is an important tool for obtaining detailed information about a specific user group.When we need to display the user group name, description, level, or settings on the page, this tag is used.During use, you may notice that it provides the `id` and `level` parameters to specify the user group to be queried, so what is the difference between them and how should they be chosen?

2025-11-07

How to ensure that the `userGroupDetail` tag returns the correct context of the current page?

Running a website on AnQi CMS, flexibility and accuracy are crucial.Especially when we need to display content based on user identity or specific requirements, ensuring that the user group data obtained matches the context of the current page is the basis for personalized experience and permission control.Today, let's delve into how to make full use of the `userGroupDetail` tag to ensure that we can always obtain the correct user group data.

2025-11-07

How to make conditional judgments in the template using the `userGroupDetail` tag to get the user group level (`Level`)?

When managing users and content in AnQiCMS, we often encounter the need to display different content based on user identity, such as exclusive articles that only VIP members can watch, or different function buttons that users of different levels can see.At this time, the `userGroupDetail` tag and the user group level (`Level`) it retrieves become the key tool for us to implement conditional judgment in the template.AnQiCMS as a flexible and efficient content management system, its template engine provides friendly support for Django template syntax

2025-11-07

What will the `userGroupDetail` tag return if the user group ID or Level does not exist, and how should it be handled?

In AnQiCMS template development, the `userGroupDetail` tag is undoubtedly the core tool for obtaining user group information, allowing us to flexibly retrieve detailed information according to the user group ID or level, thus realizing member level display, specific content access permission control, and other functions.However, in practical applications, we often encounter a problem: what will this tag return when the requested user group ID or Level does not exist?How should we properly handle this situation to avoid unexpected blank pages or error messages on the page

2025-11-07