How to retrieve and display the friend link list in AnQiCMS template?

Calendar 👁️ 63

In website operation, friendship links are an important factor in improving website weight, increasing external traffic, and optimizing user experience.AnQiCMS (AnQiCMS) knows this, therefore it provides a convenient link management function in the system design, and supports flexible calls and display in templates.This article will introduce you in detail how to obtain and display the friend link list in your AnQiCMS template.

Management of friend links: Starting from the background

Before calling the template, first make sure that the link management function of your website background is configured. The AnQi CMS link management function is located atfunction managementUnder the module. Here, you can add new友情链接 links, edit information of existing links, including the link name (Title), target address (Link), brief remarks (Remark), and whether to enable the "nofollow" attribute (Nofollow).

The “nofollow” attribute is very important for SEO, as it tells search engines not to follow the link. This is very useful when linking to external websites and not wanting to pass on your own weight.AnQiCMS provides the convenience of checking this option for you in the background.

These friendship links configured in the background are the data source we will obtain and display in the front-end template.

The core tag for obtaining friendship links in the template:linkList

AnQiCMS provides a namedlinkListThe dedicated template tag is used to retrieve and display the friend links configured on the back-end of your website.This label is designed to be very intuitive, allowing you to easily integrate link data into any template location.

Basic syntax is as follows:

{% linkList 变量名称 %}
    {# 在这里放置循环代码来遍历和显示友情链接 #}
{% endlinkList %}

Here, 变量名称Is a custom name you use to store the list of friend links, for examplefriendLinks.linkListThe tag will retrieve all enabled friend links and assign them to the specified variable as a list object.

Detailed explanationlinkListThe use of tags

due tolinkListThe tag will return the friend link as a list (or array), therefore, you need to use the AnQiCMS template engine providedforLoop the tag to iterate and display each friend link.

Each friend link item contains the following available information:

  • item.Title: Display name of the friend link.
  • item.Link: The target URL address of the friendship link.
  • item.Remark: Remarks information of the friendship link, usually used for brief descriptions or prompts.
  • item.NofollowA boolean value (or 0/1 as a number), indicating whether the link has been setrel="nofollow"property. Whenitem.Nofollowis set to 1, it indicates that it has been set.

Here is a complete code example demonstrating how to retrieve and display friend links in your template:

{# 使用linkList标签获取友情链接列表,并将其存储在名为friendLinks的变量中 #}
{% linkList friendLinks %}
    {# 首先判断friendLinks变量是否存在且不为空,以避免在没有链接时显示空区域 #}
    {% if friendLinks %}
        <div class="footer-links">
            <h3>友情链接</h3>
            <ul class="friendship-links-list">
                {# 遍历friendLinks中的每一个友情链接项目,每个项目命名为item #}
                {% for item in friendLinks %}
                    <li>
                        {# 创建a标签,设置链接地址为item.Link,显示文本为item.Title #}
                        {# 使用target="_blank"确保链接在新窗口打开,提高用户体验 #}
                        {# 根据item.Nofollow的值判断是否添加rel="nofollow"属性,保障SEO策略 #}
                        <a href="{{item.Link}}" {% if item.Nofollow == 1 %} rel="nofollow"{% endif %} target="_blank">{{item.Title}}</a>
                        {# 如果存在备注信息,可以将其显示在链接旁边,通常用span标签包裹并添加样式 #}
                        {% if item.Remark %}
                            <span class="link-remark">{{item.Remark}}</span>
                        {% endif %}
                    </li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}
{% endlinkList %}

Place this code in the template file where you want to display the friend links (for example, the footer filepartial/footer.htmlor the sidebar filepartial/sidebar.htmlIn it, save and you will see the effect on the front page. You can beautify the display effect of the friendship link by modifying the HTML structure and adding CSS styles, so that it matches the style of your website.

in a multi-site scenariositeIdParameter

If you are using the multi-site management feature of AnQiCMS and want to callother sitesthe friend link list of a site template,siteIdTo implement the parameter. For example, if you want to call the friendship link of the site with ID 2:

{% linkList friendLinks with siteId="2" %}
    {# 循环显示 ID 为 2 的站点的友情链接 #}
{% endlinkList %}

In most single-site cases, this parameter does not need to be manually set, the system will default to obtaining the current site's link.

Consider integrating the link into the template in practice.

  1. Location selection:The most common places for friend links are the website's footer, sidebar, or an independent 'friend links' page.Choose a location that is friendly to both users and search engines.
  2. Customize the style:By default, the template tag only outputs the HTML structure of **.You need to design the overall website, and add styles to the friend link list through CSS, such as font, color, layout, etc., to ensure that they are beautiful and easy to read.
  3. Quantity control:Although friend links are beneficial, more is not necessarily better. Too many friend links may dilute page authority and may even be considered as a cheating behavior by search engines.It is recommended to maintain a moderate quantity and prioritize high-quality, relevant links.

By following these steps and code examples, you should be able to easily retrieve and display the friend link list in the AnQiCMS template, adding more value to your website.


Frequently Asked Questions (FAQ)

  1. Why have I added a friend link in the background, but it doesn't show on the website front end?

    • Please check if you have used the template file correctlylinkListtags, and within the tags,{% for ... %}Loop is also correctly written.
    • Confirm that your友情 link is enabled in the background.
    • Check if the template file contains similar{% if friendLinks %}Such a conditional statement, if the list is empty, this code may cause the entire friend link area not to display.
    • If there is a cache on the page, try to clear the system cache of AnQiCMS.
  2. How to make a friendship link open in a new window (new tab)?

    • Before your<a>the tag withtarget="_blank"Just attributes. For example:<a href="{{item.Link}}" target="_blank">{{item.Title}}</a>The example code provided in this article already includestarget="_blank".
  3. Can I display the remarks filled in by the administrator in the background next to the友情 links?

    • Yes. Each item in the友情 links includesitem.Remarkfield. You just need to<a>near the tag, use{{item.Remark}}To display note information. For example:<li><a href="{{item.Link}}" target="_blank">{{item.Title}}</a> {% if item.Remark %}<span class="link-remark">({{item.Remark}})</span>{% endif %}</li>.

Related articles

How to display the Tag list associated with the article in AnQiCMS?

In AnQiCMS, effectively managing and displaying the tag (Tag) list of articles can not only help with content organization but also significantly improve the internal link structure and search engine optimization (SEO) effect of the website.Labels as a flexible classification method can link articles across categories and themes, providing users with a richer browsing path. ### Manage and create article tags in the background First, understanding how to add and manage article tags in the AnQiCMS background is fundamental.

2025-11-08

How to call and display the form fields submitted by users in the AnQiCMS template?

AnQi CMS provides a flexible mechanism to handle the interactive content of websites, among which the message form is an important bridge for communication with users.When we need to collect diverse information from users, we often create custom message fields.How to accurately call and display these custom form fields configured in the backend template on the website's frontend, which is the key to achieving personalized user experience.In AnQiCMS, the display of the message form fields mainly depends on the use of template tags.

2025-11-08

How does AnQiCMS display the comment list on article or product detail pages?

In website operation, user interaction is an important link to enhance the value of content and the level of website activity.The comment function serves as a bridge for users to directly communicate with content, not only enriching the page content, but also bringing unique UGC (User Generated Content) to the website, enhancing the community atmosphere, and also positively affecting search engine optimization (SEO).AnQiCMS (AnQiCMS) provides a powerful and flexible comment list display feature, allowing you to easily display user comments on articles or product detail pages and manage them effectively.

2025-11-08

How to dynamically display the breadcrumb navigation of the current page in AnQiCMS template?

Build a user-friendly, SEO-friendly website in AnQiCMS, breadcrumb navigation is an indispensable element.It can clearly show the user's current location, help the user quickly backtrack, and provide valuable website structure information for search engines.AnQiCMS's powerful template engine provides a simple and efficient way to dynamically generate these navigation paths.AnQiCMS's template system adopts syntax similar to the Django template engine, which makes it very easy for content developers to control the display of page content through tags and variables

2025-11-08

How to display the document list under a specific Tag in AnQiCMS?

In AnQiCMS, tags (Tag) are a powerful and flexible way to organize content, allowing you to associate documents in multiple dimensions without relying on traditional hierarchical classification structures.When you want to display all documents under a specific topic or keyword, it is particularly important to show the document list under a specific tag.This not only helps visitors find the content they are interested in faster, but also effectively improves the internal link structure and SEO performance of the website.

2025-11-08

How to dynamically retrieve and display the contact information of the website in AnQiCMS?

In today's digital age, a website's contact information is more than just cold numbers or addresses; it is a bridge for users to build trust and communicate with the company.Efficiently and accurately display this information on the website, and be able to update it flexibly as needed, which is crucial for any website operator.AnQiCMS as an enterprise-level content management system provides a very intuitive and powerful solution in this aspect, allowing you to easily manage these key information without touching complex code.This article will introduce how to configure and dynamically obtain the contact information of the website in AnQiCMS

2025-11-08

How to use the `if` tag for conditional judgment to control content display in AnQiCMS templates?

How to use the `if` tag for conditional judgment to control content display in AnQiCMS templates?When building website templates, we often need to display or hide specific content blocks based on different conditions.For example, the image will be displayed only when the article has a thumbnail, or the welcome message will be displayed only after the user logs in.In the AnQiCMS template system, the `if` tag is a powerful tool for implementing conditional judgments.It uses a syntax similar to the Django template engine, concise and expressive, making the content display logic clear and easy to understand

2025-11-08

How to use a `for` loop to iterate over data and display content in AnQiCMS templates?

In AnQiCMS template development, we often need to display a series of dynamic content, such as the latest article list, product categories, navigation menu items, and even custom parameters.At this point, the 'for loop' has become the core tool for us to traverse these data and display it on the web page.Understand and master the `for` loop, which will greatly enhance the flexibility and development efficiency of the template.### Core Grammar: The Foundation of Data Traversal The `for` loop syntax in AnQiCMS templates is concise and intuitive, borrowing the style of the Django template engine.

2025-11-08