How to use the `add` filter to dynamically add navigation arrow symbols to the titles of `nextArchive` or `prevArchive`?

Calendar 👁️ 60

In website content operation, the subtle aspects of user experience often determine the overall effect.For the article detail page, if the "Previous" and "Next" navigation at the bottom of the page can be designed more intuitively, it will undoubtedly greatly improve the user's browsing efficiency and comfort.This article will discuss how to make use of the powerful template functions of Anqicms, especially the ones inaddFilter, dynamically add arrow symbols to these navigation titles to make them clear.

Understand the requirements: Why do we need to dynamically add navigation arrows?

Imagine when a user finishes reading an exciting article and is ready to view more related content. If there were clear arrow indicators next to the 'Previous' or 'Next' text navigation, it would be such a considerate design.A left arrow (such as “«”) can intuitively tell the user that this is the path to return to old content, while a right arrow (such as “») indicates that there is updated content waiting to be explored.This visual guidance not only helps users quickly understand the navigation intention, but also adds a sense of delicacy to the page design, enhancing the overall user experience.

Core Tool:addThe wonder of filters

The Anqi CMS template system provides a rich set of tags and filters, includingaddThe filter is the key to meet this requirement. It can very flexibly connect or add two values. Whether it is the simple addition of numbers or the concatenation of strings,addFilters can handle it easily.

The basic usage is:{{ 值1|add:值2 }}.

For example, if we want to concatenate two strings, we can write it like this:{{ "安企"|add:"CMS" }}The final result will be:安企CMS

In our scenario, it is used to concatenate the article title (a string) with an arrow symbol (another string).

Gradually practice: Add a right arrow to the title of the next article

First, let's focus on the navigation of the next article. In Anqi CMS, we usually usenextArchiveTag to get the information of the next article. This tag will return an object containing detailed data of the next article, and we can access it bynext.TitleTo get its title.

The basic "next page" navigation code may look like this:

{% nextArchive next %}
  {% if next %}
    <a href="{{next.Link}}">{{next.Title}}</a>
  {% else %}
    <span>没有了</span>
  {% endif %}
{% endnextArchive %}

Now, we try to addnext.Titlea right arrow. The symbol of the right arrow can be simpleor more graphical». We will useaddThe filter appends this arrow symbol to the end of the title:

{% nextArchive next %}
  {% if next %}
    <a href="{{next.Link}}">{{next.Title|add:" »"}}</a>
  {% else %}
    <span>没有了</span>
  {% endif %}
{% endnextArchive %}

In this code block,|add:" »"that isaddThe application of the filter. It willnext.Titleappend a space and an arrow symbol to the string value»Concatenate together. If your arrow symbol is an HTML entity, for example&raquo;, you may need to配合 to ensure that the browser can correctly parse the HTML entity rather than displaying the original code.safeFilter, for example, use it like this:{{next.Title|add:" &raquo;"|safe}}.

Follow the same method: add a left arrow to the title of the previous article

Similarly, for the previous article, we useprevArchiveLabel to get its information and throughprev.Titleto get the title.

Basic 'Previous' navigation code may look like this:

{% prevArchive prev %}
  {% if prev %}
    <a href="{{prev.Link}}">{{prev.Title}}</a>
  {% else %}
    <span>没有了</span>
  {% endif %}
{% endprevArchive %}

In order to add a left arrowhead to the title of 'Previous Article', we place the arrow symbol in front of the title. It is important to note the order of concatenation, placing the arrow string inaddThe location of the filter parameters:

{% prevArchive prev %}
  {% if prev %}
    <a href="{{prev.Link}}">{{ "« "|add:prev.Title }}</a>
  {% else %}
    <span>没有了</span>
  {% endif %}
{% endprevArchive %}

In this example,"« "|add:prev.TitleCombine the left arrow symbol, a space withprev.Titlethe string value to achieve the display effect of "<< Title".

Beautify and customize: choose your favorite arrow symbol

There are many choices for arrow symbols, you can choose the most suitable one according to the overall style of the website and the design preference of the user interface. Here are some commonly used arrow symbols that you can copy and use directly:

  • Simple text arrow:
    • Left:<or
    • Right:>or
  • Double arrow (emphasizing direction more):
    • Left:«or«(HTML entity)&laquo;)
    • Right:»or»(HTML entity)&raquo;)
  • Triangle arrow:
    • Left:(HTML entity)&#9664;)
    • Right:(HTML entity)&#9654;)
  • Combined symbol:
    • Left:(HTML entity)&lsaquo;)
    • Right:(HTML entity)&rsaquo;)

Remember, if you are using HTML entities (such as&laquo;), please make sure toaddadd it after the filter|safesuch as{{ " &laquo;"|add:prev.Title|safe }}.

Expand Thinking:addMore Application Scenarios of Filters

Besides adding an arrow to the article title,addThe filter is widely used in the template design of Anqi CMS. For example, you can use it to:

  • Dynamically combine complex CSS class names: class="item {{ 'active'|add:category.Id }}"
  • Generate custom prompt information: <span>{{ '当前用户:'|add:user.Name }}</span>
  • Concatenating data from different fields to

Related articles

How to dynamically add language parameters in the `add` filter of the `languages` tag that returns multilingual site links?

Under the flexible multi-language support of AnQiCMS, providing content to users worldwide has become very convenient.The system built-in `languages` tag can easily list all the language versions supported by your website and their corresponding links.However, in some scenarios, we may not only want to provide language switching functionality, but also dynamically add additional parameters to these multilingual links, such as for marketing tracking, A/B testing, or loading personalized content in specific languages.

2025-11-07

Can the `add` filter be used to concatenate CSS style strings to implement dynamic inline styles?

AnQiCMS with its flexible and powerful template engine provides great convenience to users, allowing content presentation to be highly customized according to actual needs.In daily template development, we often encounter scenarios where we need to dynamically adjust the page display based on backend data, such as changing the title color based on the article reading volume, or displaying different background styles based on user permissions.At this point, we might wonder whether the built-in `add` filter of AnQiCMS templates can be used to concatenate CSS style strings to achieve these dynamic inline style controls

2025-11-07

How to dynamically display

Display the record number at the bottom of the website, which is not only a requirement to comply with relevant laws and regulations, but also an important factor in enhancing the professionalism and user trust of the website.For users of AnQiCMS, dynamically displaying the filing number through the built-in powerful functions of the system is a very convenient operation, eliminating the need to frequently modify the code and greatly improving the maintenance efficiency of the website. ### Set the record number content in the background First, we need to set your website record number in the AnQi CMS background management interface. This is the basis of all dynamic display content, ensuring the accuracy of information

2025-11-07

`add` filter combined with `default` filter to set default values for variables that may be empty before concatenation?

In the daily operation of AnQi CMS, we often need to concatenate different field content to form a complete information, such as generating a complete address or combining an attractive product title.However, a common challenge with dynamic content is that some variables may be empty.If concatenated directly, the blank content not only affects the appearance but may also lead to missing information or disordered format.Fortunately, AnQiCMS's powerful Django template engine grammar provides us with a flexible solution

2025-11-07

How to implement the dynamic combination output of the `add` filter in the custom `diy` tag?

In AnQi CMS, content operation not only seeks accurate transmission of information, but also flexibility and automation of expression.We often encounter such needs: we hope to combine some independent content preset by the background with dynamic data on the page or fixed text in a clever way, forming a complete and creative expression.Today, let's delve deep into how the `add` filter and custom `diy` tags work together in Anqi CMS to help us achieve this dynamic combination of content output.### `diy` label: your content treasure box first

2025-11-07

How to use the `add` filter to dynamically add username and timestamp to the `commentList` comments?

AnQiCMS (AnQiCMS) with its flexible and powerful template engine, enables the presentation of website content to have a high degree of freedom.In website operation, the comment section is an important place for user interaction. Clearly displaying the information of the commenters can effectively enhance the reading experience and interaction atmosphere of the comment content.This article will introduce you in detail on how to use the `add` filter to dynamically add user nickname and timestamp to comments in `commentList`. ### Flexibly display comment data: Starting from `commentList` At

2025-11-07

Can the `add` filter directly add two numeric strings (such as "123" and "456") to get the numeric result 779?

AnQi CMS is a high-efficiency and feature-rich enterprise-level content management system, whose template engine provides flexible data processing capabilities.During template development, making good use of various filters can help us accurately control the display format of content.Today, we will delve into a common filter——`add`, especially its specific performance in handling numeric strings, which is often a place where users are likely to have doubts.

2025-11-07

How to implement multi-site content unified display and management in Anqi CMS?

In today's era where digital marketing and brand building are increasingly important, many companies or individuals often need to manage multiple websites, whether it is different brands, product lines, or multilingual, regional sites.Faced with the need for multi-site content management, AnQiCMS (AnQiCMS) provides a graceful and efficient solution that helps us easily achieve the unified display and management of content. **The Core Concept of Multi-Site Management in AnQi CMS** One of the design philosophies of AnQi CMS is that 'one system manages all'.

2025-11-07