How to dynamically display exclusive content for distributors based on the user's `IsRetailer` status in AnQiCMS templates?

Calendar 👁️ 61

Today, providing customized experiences for users of different types has become the key to improving user satisfaction and business efficiency.For businesses that have a distribution system, how to ensure that distributors can easily access their exclusive content without causing interference to ordinary users is a common need.AnQiCMS with its flexible template engine and powerful user management features, can help you easily achieve this goal.

Today, let's delve into how to dynamically display content exclusive to distributors in the AnQiCMS template, based on the user'sIsRetailerstatus.

UnderstandingIsRetailerStatus: Your distributor identity identifier

In the AnQiCMS user management system,IsRetailerIt is a very practical user attribute. It is essentially a boolean value (true or false) used to clearly identify whether a user has the identity of a distributor.After you set the distributor role for a user in the background, thisIsRetailerthe status will be activated.

The meaning of this state is that it provides a direct basis for content filtering and display in the front-end template.We can imagine, some content, such as internal training materials, preferential distribution prices, exclusive marketing tool downloads, and so on, are intended to be opened only to distributors.By using the template function of AnQiCMS, we can skillfully make use ofIsRetailerStatus, seamlessly present these contents to distributors while hiding them from other users.

Core logic in the template: conditional judgment and user detail tags

The template engine of AnQiCMS is designed to be very intuitive, it borrows the syntax of Django templates, making conditional judgments simple to perform. The core idea of dynamically displaying exclusive content for distributors is to first obtain the current user'sIsRetailerStatus, then make a conditional judgment based on this status to determine which content should be displayed.

Here, we need to use a very important tag in the AnQiCMS template——userDetail. This tag allows us to retrieve the detailed information of the currently logged-in user. Specifically, we can do it like thisIsRetailerStatus:

{% userDetail isRetailerStatus with name="IsRetailer" %}

This line of code will set the current user'sIsRetailerStatus (a boolean value,trueorfalseAssign to a variable namedisRetailerStatus. Next, we can useifLabel, based onisRetailerStatusto control the display of content.

For example, a basic conditional judgment structure might look like this:

{% userDetail isRetailerStatus with name="IsRetailer" %}

{% if isRetailerStatus %}
    {# 这里放置分销员才能看到的内容 #}
    <div class="retailer-exclusive-content">
        <p>欢迎回来,尊敬的分销员!您可以看到这些专属内容。</p>
        <!-- 更多分销员专属信息... -->
    </div>
{% else %}
    {# 这里放置普通用户或未登录用户看到的内容 #}
    <div class="general-content">
        <p>您好!部分内容仅对分销员开放。</p>
        <a href="/register">注册成为分销员</a>,获取更多权益!
    </div>
{% endif %}

In this way, you can insert this logic anywhere on the page to achieve fine-grained content control.

Useful scenario: exclusive content display for distributors.

Let us go through several specific examples to see how to utilizeIsRetailerstatus。“

Scenario one: Displaying different distribution prices on the product page

Assuming your product page needs to display a special purchase price for distributors. You can add a custom field for the product in the content model, such asRetailerPriceFor storing the distributor price.

{# 假设您正在产品详情页,archive 变量已包含产品信息 #}
{% userDetail isRetailerStatus with name="IsRetailer" %}

<div class="product-info">
    <h2>{{ archive.Title }}</h2>
    <p>市场零售价: <span>{{ archive.Price }}</span> 元</p>

    {% if isRetailerStatus %}
        <p class="retailer-price">分销员专属价: <span>{{ archive.RetailerPrice }}</span> 元</p>
        <button class="buy-now-retailer">立即采购</button>
    {% else %}
        <p>如果您是我们的分销员,可享受更优惠的采购价格。</p>
        <button class="add-to-cart">加入购物车</button>
    {% endif %}

    <div class="product-description">
        <h3>产品详情</h3>
        {{ archive.Content|safe }}
    </div>
</div>

In this way, after the distributor logs in, they will automatically see the exclusive price, while ordinary users will see the market price.

Scenario two: Hidden exclusive download link in article or page

If your website provides some materials exclusively for distributors to download, such as promotional brochures, high-quality image materials, etc., you can wrap these download links in conditional judgments within articles or single pages.

{# 假设您正在文章详情页 #}
{% userDetail isRetailerStatus with name="IsRetailer" %}

<article>
    <h1>{{ archive.Title }}</h1>
    <div class="article-content">
        {{ archive.Content|safe }}
    </div>

    {% if isRetailerStatus %}
        <div class="download-section retailer-only">
            <h3>分销员专属下载区</h3>
            <p>这里提供最新的产品手册、营销海报源文件等,助您更好地开展业务。</p>
            <ul>
                <li><a href="/files/product-manual-retailer.pdf" download>产品手册(分销版)</a></li>
                <li><a href="/files/marketing-poster-source.zip" download>营销海报源文件</a></li>
            </ul>
        </div>
    {% else %}
        <div class="download-section guest-prompt">
            <p>如需获取更多营销资料,请<a href="/login">登录</a>或<a href="/register">注册</a>成为我们的分销合作伙伴。</p>
        </div>
    {% endif %}
</article>

This way, only users withIsRetailerstatus can view and download these files.

Related articles

How to format `LastLogin` (last login time) into a readable date using the `stampToDate` tag?

In website operation and management, user behavior data is an important basis for improving user experience and formulating strategies.Among them, the "LastLogin" is a direct indicator of user activity.However, this data is usually stored in the form of raw timestamps, and for ordinary users, a string of numbers is far less friendly and understandable than a direct date and time.AnQi CMS provides powerful template tag functions, among which the `stampToDate` tag is a powerful tool to solve this problem, it can help us easily convert abstract timestamps into clear and readable date formats

2025-11-07

The `userDetail` tag supports which parameters to accurately find specific user information?

In AnqiCMS template development, to display specific user information on the page, we often use a very practical tag - `userDetail`.This tag allows us to accurately retrieve and present detailed user data based on specific conditions.Understanding the parameters it supports is crucial for flexibly building user-related page functions.The core function of the `userDetail` tag is to obtain data based on a clear user identifier.When in use, it requires us to specify the user ID to be queried through the `id` parameter

2025-11-07

How to use the `userDetail` tag to retrieve the user's real name `RealName` on the frontend page?

In website operations, personalization and user experience are the key to enhancing brand image.Sometimes, we are not satisfied with just displaying the user's nickname or avatar. In certain scenarios, such as the member center, profile page, or some activity leaderboard, we may also need to display the user's real name.AnQi CMS is a highly flexible and feature-rich Go language content management system that provides intuitive template tags, allowing front-end developers to easily retrieve and display this information.Today, let's delve into how to use the `userDetail` tag of Anqi CMS

2025-11-07

How to correctly display the user's `UserName` (username) in the AnQiCMS template?

In AnQiCMS templates, flexibly displaying user information is a key link to enhance website personalization and user experience.Whether it is to display the nickname of the comment author or to show the detailed information of the registered user on a specific page, it is very important to understand how to correctly call `UserName`. AnQiCMS's powerful template engine provides multiple ways to achieve this goal, and we will delve deeper into these methods next.AnQiCMS's template system adopts a syntax similar to the Django template engine, which allows developers to quickly build pages in a concise and efficient manner

2025-11-07

How to get the user's account balance `Balance` and cumulative earnings `TotalReward` through the `userDetail` tag?

How to retrieve and display a user's account balance and cumulative earnings in AnQi CMS template?For operators, it is a key element to enhance user experience and manage the membership system by flexibly displaying user-specific information on the website, such as their account balance or cumulative earnings.AnQi CMS is a powerful and practical content management system that provides a very convenient way to obtain these user data.Today, let's talk about how to use your template

2025-11-07

Can the `userDetail` tag retrieve the user's email `Email` and phone number `Phone` and display it on the front end?

In website operation and user experience design, sometimes we need to display specific user information on the front-end page, such as contact email or phone number, in order to provide personalized services or facilitate users to view/update their personal information.It is crucial for users of AnQiCMS to understand how to implement this safely and efficiently.This article will delve into the `userDetail` tag of AnQiCMS, discussing whether it can retrieve and display the user's email (`Email`) and phone number (`Phone`), as well as the matters that need to be paid attention to during use

2025-11-07

How to use `AvatarURL` or `FullAvatarURL` to display a user avatar in the template?

In website operation, the user avatar is not just a decoration, it carries the user's identity and is an important part of community interaction and personalized experience.Whether it is in the comment area, author introduction, or member center, a clear user avatar can significantly enhance the website's affinity and professionalism.AnQiCMS as an efficient content management system naturally also provides us with the powerful function of flexibly displaying user avatars in templates.Today, let's talk about how to use the `AvatarURL` and `FullAvatarURL` fields in AnQiCMS templates

2025-11-07

How to get the `GroupId` of the user through the `userDetail` tag and further get the detailed information of the user group?

In AnQiCMS, providing personalized content and experience to users is a key link to enhance website stickiness.It is particularly important to understand the details of the user's group to display exclusive content based on user level or provide differentiated service information.Today, let's delve into how to make use of the powerful template tag features of AnQiCMS, through the `userDetail` tag to obtain the `GroupId` of the user, and further use the `userGroupDetail` tag to display the detailed information of these user groups on the website front end

2025-11-07