How to call and display friend links in AnQiCMS templates?

Calendar 👁️ 73

Friendship links, as part of the website content ecosystem, not only help to improve search engine rankings and optimize website authority, but also provide users with more related resource navigation.In AnQiCMS, managing and displaying friend links is a direct and flexible task, even if you don't have a strong programming background, you can easily achieve it.

Backend management: easily configure the friend link

On the AnQiCMS backend management interface, you will find the settings for the link of friendship located under the "Function Management" menu.Click to enter the 'Friend Links' page, where you can centrally manage all external collaboration links.You can conveniently add new friendship links, edit existing link information, or remove links that are no longer in cooperation as needed.

When adding or editing a link, the system will prompt you to fill in several key pieces of information:

  • Link Name (Title): This is the name displayed on the website for the friend link.
  • Link AddressThis is the target URL of the友情链接 friendship link
  • Remark for Link: You can add some internal notes to the link for easy management, these notes are usually not displayed on the front end.
  • NofollowThis is an important SEO option. If this option is checked, the link will includerel="nofollow"The attribute tells the search engine not to pass the weight of the current website to the target link. This is very useful in some advertising collaborations or in scenarios where you do not want to pass the weight of external links.

After completing these settings, the background friend link data is ready, next let's take a look at how to display them in the website front-end template.

Template call: withlinkListTag

AnQiCMS provides a user-friendly template tag system to call various data in the front-end template, including friend links. The core tag for calling friend links islinkList. This tag can help you get all the friendship link data configured in the background.

Generally, friendship links are placed in the footer area of the website, so you may find them in the public footer template file of the website (such asfooter.htmlOr throughincludePerforming operations on the public file included by tags. Here is a typical template code example for displaying friend links:

{% linkList friendLinks %}
    {% if friendLinks %}
    <div class="friendship-links">
        <h3>友情链接</h3>
        <ul>
            {% for item in friendLinks %}
            <li>
                <a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>
            </li>
            {% endfor %}
        </ul>
    </div>
    {% endif %}
{% endlinkList %}

Let's parse this code step by step:

  1. {% linkList friendLinks %}This line of code is a call to:linkListThe start of a tag, which declares a variable namedfriendLinks. AnQiCMS will load all the friendship link data set in the background to this variable.
  2. {% if friendLinks %}This is a simple conditional judgment, used to checkfriendLinksDoes the variable have data. If there is a friend link, the internal code will continue to execute, which helps to avoid displaying an empty friend link area when there is no friend link.
  3. {% for item in friendLinks %}: Due tofriendLinksis an array containing multiple friendship link objects, we need to useforloop to traverse each link in the array. In each loop,itemthe variable represents the current friendship link object.
  4. <li>...</li>In the loop, we use<li>tags to wrap each link, which is the standard practice for list items in HTML.
  5. <a href="{{item.Link}}" ...>{{item.Title}}</a>This is the actual display part of the link.
    • href="{{item.Link}}": Pass{{item.Link}}Output the current URL of the friendship link.
    • target="_blank"This is usually added to the friendship link to ensure that the link opens in a new window or tab when clicked, to avoid the user leaving the current website.
    • {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is a dynamically addedrel="nofollow"fragment of the attribute. If the current link is marked as "Nofollow" in the background, then this attribute will be added to<a>the tag.
    • {{item.Title}}: Pass{{item.Title}}Display the current link name.

With such a structure, you can flexibly control the style and display of the link, fully integrating it into the overall design of your website.

consideration and practice across multiple sites

AnQiCMS supports multi-site management, if you are operating multiple websites under the same system and want to call exclusive or shared friend links on specific sites,linkListLabels also providedsiteIdParameters to specify the site ID to retrieve data. However, in most single-site deployments or default scenarios, it is usually unnecessary to manually set this parameter, as the system will automatically identify and retrieve the friendship links of the current site.

On the website operation level, it is recommended that you place the friend link at the footer of the website or in other locations that do not interfere with the main content but are easy for users to find.The quality and relevance of friendship links are more important than quantity. Maintaining a moderate number of links and regularly checking the validity of links (to prevent dead links) is the key to maintaining the health and SEO performance of the website.Through AnQiCMS, all these tasks can be made more efficient and convenient.


Frequently Asked Questions (FAQ)

Q1: Can only a part of my friend links be displayed if there are too many?A1:linkListThe tag will default to retrieving all the friend links configured in the background. If you only want to display a part of them, you can control it in the{% for item in friendLinks %}loop. For example, you can use{% if forloop.Counter <= 10 %}Limit to display only the first 10 links, or use the AnQiCMS template engine filter function, such as{% for item in friendLinks|slice:":10" %}To cut the first 10 links for loop display.

Q2: Is the display order of friend links fixed? Can I customize their order on the frontend?A2: The display order of friend links on the front end usually depends on the order in which you add or adjust them in the AnQiCMS backend management interface.The system will output according to the order of the background list. CurrentlylinkListThe label itself does not provide sorting parameters, so if you need to adjust the display order, you can do so directly in the background of the friendship

Related articles

How to implement pagination and like function in AnQiCMS comment list?

The Anqi CMS plays a crucial role in content operation, where user interaction is an important factor in enhancing website activity. The comment function, along with its配套 pagination display and like function, is undoubtedly the key to achieving this goal.Benefiting from AnQiCMS's flexible template engine and rich built-in tags, we can relatively easily add these features to the articles or products of the website. ### 1.The basic enablement and configuration of the comment function Firstly, ensure that the website's comment function is enabled.

2025-11-07

How to display the Tag tag list and corresponding documents of articles in AnQiCMS template?

In AnQi CMS, the organization and display of content is diverse, and the Tag feature of the article provides users with flexible keyword association and content discovery paths.No matter if you want to display related tags on the article detail page or create a page that aggregates content with specific tags, Anqi CMS provides intuitive and powerful template tags to meet these needs. We will explore together how to effectively display the Tag tag list and its corresponding documents in the AnQiCMS template.

2025-11-07

How to implement content collection and batch import in AnQiCMS and control its final display effect?

In the current era of explosive digital content, efficient content management and refined presentation are the goals pursued by every website operator.For those who need to frequently update industry information, aggregate a large amount of materials, or manage multiple content sites, manually entering content is undoubtedly a time-consuming and labor-intensive task that is prone to errors.幸运的是,AnQiCMS provides us with powerful content collection and batch import functions, and with flexible template systems, we can easily achieve automated content updates while accurately controlling the final presentation of content.

2025-11-07

How do AnQiCMS's static cache and SEO optimization features work together to improve content loading speed and display quality?

In today's fast-paced digital world, whether a website can successfully attract and retain users, the speed of content loading and visibility in search engines are two crucial factors.We all hope that our websites can present quickly at the moment when users click on the link and stand out when users search for relevant information.

2025-11-07

How to implement pagination for document lists in AnQiCMS and support custom page number quantities?

AnQiCMS document list pagination and custom page number settings: Make your content management more efficient Imagine, when your website content becomes rich, with thousands of articles, products, or news lists neatly arranged, if you cannot organize and display them effectively, users may feel at a loss.A good pagination mechanism not only improves user experience and helps visitors quickly find the information they need, but is also an important aspect of SEO optimization.

2025-11-07

How to use conditional judgment (if/else) tags to control the display logic of content in AnQiCMS templates?

In the development and maintenance of website templates, we often encounter the need to display or hide different content based on specific conditions.This dynamic content display logic is crucial for improving user experience, realizing personalized functions, and optimizing the website structure.AnQiCMS (AnQiCMS) is a powerful content management system that provides a flexible template engine, among which the condition judgment (`if/else`) tags are the core tools to achieve this goal.

2025-11-07

How to use the (for) loop tag in AnQiCMS template to traverse and display the content list?

Efficiently using the `for` loop tag in AnQiCMS templates to display content lists is an indispensable core skill for building dynamic websites.By flexibly using the `for` loop, we can easily traverse various types of data collections and display them in a customized style on the website page, whether it is a news list, product display, category navigation, or any other repetitive content block, the `for` loop can help you a lot.

2025-11-07

How to correctly format timestamps in AnQiCMS templates so that content is displayed as needed?

In the daily operation of website content, time information plays a vital role.No matter the publication date of the article, the launch time of the product, or the latest update of the content, these time points directly affect users' perception and trust in the information.However, in the templates of content management systems, we often encounter dates stored in the form of "timestamps", which are precise but not intuitive.How should we correctly format these timestamps in the AnQiCMS template so that the content can be displayed in the way we expect?

2025-11-07