In AnQi CMS, to achieve exclusive display of paid content, it usually requires combining its powerful user group management and VIP system features.This can not only help your website effectively monetize content, but also provide differentiated service experiences for users at different levels.Next, we will step by step explore how to set up so that your exclusive content is only visible to paying users.

Understand the core concept: User groups and content reading levels

The core of implementing paid content in Anqi CMS lies in the concepts of 'user groups' and 'content reading levels'.

  • User groupYou can classify website users into different groups, such as "normal users", "VIP members", "senior VIPs", and so on.Each user group can be assigned a specific "level".
  • Content Reading Level: Each article, product, or other content you post can be set to a "Reading Level". This level corresponds to the user group level.

When a user tries to access a piece of content, the system automatically checks whether the user's group level has reached or exceeded the reading level of the content.If the condition is met, the user can view normally; otherwise, the content will be hidden or only part of the summary will be displayed.

The first step: configure user groups in the Anq CMS backend

Firstly, we need to define different user groups in the backend and set their corresponding permission levels.

  1. Log in to the backend:Use your administrator account to log in to the AnQi CMS backend management interface.
  2. Enter user group management: Find the "Administrator Management" or similar "User Management" entry in the left navigation bar, where there is usually an option for "User Group Management".
  3. Create or edit a user group:
    • Default User GroupYour website usually has a default 'regular user' group.You can edit it, for example, set its level to "0" (indicating the lowest permission, usually used for non-logged-in users or general registered users).
    • Create VIP User Group: Click the 'Add New User Group' button to create user groups such as 'VIP Member' and 'Senior VIP' and so on.
      • Set Name: Name the user group clearly, such as "VIP Member".
      • Set the level (Level)This is the key.Set the level of 'VIP Member' to '1', set the level of 'Senior VIP' to '2', and so on.These numbers will directly match the reading level of the content.The higher the level number, the higher the permission.
      • Set the purchase price (Price): If this is a paid user group, you can set the purchase price and discount price of the members here. This information can be called from the front-end page to display VIP purchase options.
      • Setting Introduction (Description): Briefly describe the benefits of the user group, convenient for your own management and display on the front end.
  4. Save SettingsAfter completing the configuration of the user group, remember to save the changes.

With such settings, we have laid the foundation for the website's user system, and user groups of different levels are ready.

Step two: Set exclusive reading permissions for paid content

Next, we need to associate the content you want to set as paid or exclusive with a specific user group level.

  1. Enter content managementIn the left navigation bar of the background, click "Content Management", then select "Document Management" or any other content model you need to set permissions for (such as "Product Management" or "Page Management").
  2. Add or edit contentFind the article, product, or other content you want to set as exclusive display, click 'Add Document' or 'Edit' to enter the content editing interface.
  3. Set the 'Document Reading Level' (ReadLevel):
    • In the content editing page, carefully look for the "Other Parameters" or similar advanced settings options.Here, you will find a field named 'Document Reading Level' (or similar, such as 'ReadLevel').
    • Set the value of this field to the 'level' of the VIP user group you want this content to belong to.
      • For example, if you want this content to be visible only to "VIP members" (level 1) and above, set the "Document Reading Level" to "1".
      • If set to "2
      • If you keep it as "0" (or not set, the default is 0), it means all users (including ordinary users and unlogged users) can view.
  4. Save content: After setting up, remember to save your content.

Now, your content has been marked as exclusive content of a specific level.

Step 3: Implement the exclusive display logic of content in the front-end template.

This is the most critical step, we need to modify the front-end template file to dynamically display content based on the user's VIP level.

The AnQi CMS template system is very flexible, you can use built-in tags and conditional judgments to implement this logic.

  1. Confirm template file: Generally, the template files for the article detail page may be locatedtemplate/{您的模板目录}/{模型table}/detail.htmlorarchive/detail.htmlin the paths. You need to find the corresponding detail template for the content.

  2. to introduce user informationIn the top of the template file, we need to obtain the detailed information of the current visiting user, especially their user group level.

    {# 假设您有一个全局的当前登录用户对象,或者通过某种方式获取用户ID #}
    {# 这里以获取当前登录用户的Level为例,未登录或普通用户默认为0 #}
    {% set currentUserLevel = 0 %}
    {% if userId %} {# 假设userId是当前登录用户的ID,可从会话或全局变量获取 #}
        {% userDetail user with name="GroupId" id=userId %}
            {% userGroupDetail group with name="Level" id=user.GroupId %}
                {% set currentUserLevel = group.Level %}
            {% enduserGroupDetail %}
        {% enduserDetail %}
    {% endif %}
    

    Description: userIdIt may be necessary for you to obtain from the current page context or session. If the user is not logged in,userIdit will be empty,currentUserLevelit will remain the default 0.

  3. to obtain the content reading level: in the content detail page template,archiveDetailThe label can directly obtain the various attributes of the current content, includingReadLevel.

    {% archiveDetail currentArchive with name="ReadLevel" %}{# 获取当前文档的阅读等级 #}
    {% set contentReadLevel = currentArchive %} {# 将阅读等级赋值给变量方便后续使用 #}
    
  4. **Write conditions