How to get and display the list of friendship links configured in the AnQiCMS background?

Calendar 👁️ 66

In website operation, friendship links play an indispensable role. They not only bring valuable external traffic to the website but also help to improve the search engine optimization (SEO) effect, enhance the authority and credibility of the website.For users who use AnQiCMS, managing and displaying friend links is a simple and efficient process.This article will introduce in detail how to configure the友情链接 in AnQiCMS backend, as well as how to elegantly present them in your website front-end template.

Manage friend links in AnQiCMS backend

First, in order to display the link of friendship on your website, you need to configure it in the AnQiCMS backend.AnQiCMS provides an intuitive management interface that allows you to easily add, edit, and delete friend links.

Log in to your AnQiCMS backend and you can find the "Friend Links" option in the "Function Management" section of the left menu.Click to enter, you will see a list page displaying all the currently configured friend links.Here, you can click the 'Add New Link' button.

On the interface for adding or editing friend links, you usually need to fill in the following information:

  • Link name:This is usually the text of the friend link that will be displayed on your website.
  • Link address:This is the URL pointing to the friendship link.
  • whethernofollow:This is an important SEO option. If checked, it will add to the link.rel="nofollow"Attribute, tell the search engine not to pass the 'weight' to this link, which is very helpful for managing the SEO risk of external links.
  • Display order:Used to control the order of the links.

After filling in the information, save it. In this way, your friend link data has already been stored in the AnQiCMS database.

Display the friend link in the front-end template

After the background data configuration is completed, the next step is to show these links on the website's front-end template.The powerful template system of AnQiCMS makes this process very intuitive, it uses syntax similar to Django template engine, making content presentation flexible and simple.

We need to use AnQiCMS built-in to retrieve and display the friend link list in the templatelinkListLabel. This label is specifically used to retrieve the friend link data configured on the background.It will return an array (or slice) object containing all the configured friendship links, and we can simply iterate over this array to display the links one by one on the page.

Generally, friend links are placed in the footer area of a website or on a separate "friend links" page. Here is an example code snippet showing how to display friend links in a template:

{% linkList friendLinks %}
    {% if friendLinks %}
    <div class="footer-links">
        <h4>友情链接</h4>
        <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 break down this code and see how it works:

  1. {% linkList friendLinks %}: This is the core tag, indicating that AnQiCMS should retrieve all the friend link data and assign it to a variable namedfriendLinks.
  2. {% if friendLinks %}: This is a conditional judgment. Good programming practice is to check firstfriendLinksDoes the variable have actual data. If there is a friendship link, the content within the code block will be executed, which can prevent displaying empty titles or lists when there are no links, keeping the page neat.
  3. <div class="footer-links">...</div>: This is the HTML structure used to wrap the list of friend links, you can adjust the class name and structure according to your website style.
  4. {% for item in friendLinks %}IffriendLinksThere is data, thisforThe loop will iterate over each friendship link. In each iteration, the current friendship link data will be assigned toitemVariable.
  5. <li><a href="{{item.Link}}" ...>{{item.Title}}</a></li>: Inside the loop, we useitemVariables to access the properties of each link.
    • {{item.Link}}Displays the current friendship link's URL address.
    • {{item.Title}}It will output the display name of the current friendship link.
  6. {% if item.Nofollow == 1 %} rel="nofollow"{% endif %}: This is an inline conditional judgment. It checks whether the current friendship link is set in the background asnofollowIfitem.NofollowThe value is 1 (indicating it is checked)nofollowThenrel="nofollow"The property will be added to<a>In the tag. This allows you to precisely control the SEO attributes of each link, very practical.
  7. target="_blank"This is a common HTML attribute, usually used for friend links, indicating that the link will open in a new tab to keep the user browsing on your website.

If you have enabled the multi-site management feature in AnQiCMS and want to get the friend links of other sites in a specific site template,linkListLabels also support asiteIdthe parameters. For example,{% linkList friendLinks with siteId="2" %}You can retrieve the friend links of the site with ID 2. However, this parameter does not need to be specified in most single-site scenarios.

Summary

Configure the link through the friendly management interface of AnQiCMS backend, and combine it with the concise and powerful front-end templatelinkListLabels, you will find that displaying the website's friendship link list is a pleasant and enjoyable experience.This seamless integration of content management not only saves a lot of development time, but also ensures the flexibility and efficiency of website content management, allowing you to better focus on the operation of website content and the implementation of SEO strategies.


Frequently Asked Questions (FAQ)

Q1: What will be displayed on the front-end template if I do not add any friendship links in the AnQiCMS backend?

A1: If no friendship links are configured in the backend,{% linkList friendLinks %}Tags retrieved from comments.friendLinksThe variable will be an empty array. Since the sample code included{% if friendLinks %}this judgment, so the entire area containing thedivfriendship links (including the 'friendship links' title andulThe list) will not be rendered, no content will be displayed on the page, maintaining cleanliness.

Q2: In the friendship linknofollowWhat is the role of the attribute? When should I use it?

A2:nofollowis HTML<a>one of the labelsrelThe attribute tells the search engine not to pass the "PageRank" (page authority) from your website to the linked website. This is typically used in the following situations:

  • Link to a website you do not fully trust.
  • Link to a comment section or forum post with user-generated content (to prevent spam links).
  • Friendship link or advertising link, when you do not want to be misunderstood as 'selling link weight'.
  • If a friendship link website has low quality or does not have much relevance to your topic, usenofollowCan help you avoid potential SEO risks.

Q3: Can I customize the style and layout of the friend links?

A3: Of course you can. AnQiCMS's template system is very flexible, allowing you to fully control the front-end display of HTML structure and CSS styles. The example code contains the following.div/h4/ul/liandaLabels can be freely modified according to your design requirements. You just need to edit the corresponding template file (usuallyfooter.htmlOr other page templates that include friendship links), then add the corresponding class names or styles according to your website's CSS rules.

Related articles

How to generate and display the website's message form in AnQiCMS templates?

In website operation, an efficient and convenient feedback form is an important bridge for user interaction with the website.It not only collects user feedback, but also serves as the entry point for potential customers to obtain information.AnQiCMS as an enterprise-level content management system provides powerful and flexible functions in this aspect, allowing us to easily generate and manage comment forms in templates.

2025-11-08

How to display the comment list of a document in AnQiCMS and implement pagination?

In Anqi CMS, adding a comment list to the document page and implementing pagination is a key step to enhancing user interaction experience.This can not only let visitors participate in discussions and share opinions, but also brings more vitality to the website content.AnQi CMS provides intuitive and powerful template tags, allowing us to easily implement these features. ### Integrate the comment feature into your document detail page Comment lists and comment forms are typically integrated into the detail page of the document.

2025-11-08

How to retrieve and display the list of documents under a specific Tag label in AnQiCMS?

In Anqi CMS, managing website content, the Tag tag is undoubtedly a very flexible and practical tool that helps us classify different categories and even different model content according to themes, greatly enriching the organization of content and the browsing experience of users.So when we want to display a list of all documents under a specific Tag on a dedicated page, Anqi CMS provides a very intuitive and powerful template tag to help us achieve this goal.### Understanding the role of Tag tags in Anqi CMS Before delving into the code

2025-11-08

How to display the description and link of a specific Tag label in AnQiCMS?

In Anqi CMS, a tag is a powerful content organization tool that not only helps you classify content more finely but also optimizes the website's SEO performance and improves the user's browsing experience.Sometimes, you may wish to display not only the name of the tag at a certain position on the website's frontend, but also its detailed description information, or even jump directly to the link related to the content of the tag.This is not a difficult task, Anqi CMS provides flexible template tags, allowing you to easily meet these needs.

2025-11-08

How to format a timestamp and display it as a readable date and time in AnQiCMS?

In website content operation, time information plays an indispensable role.Whether it is the publication time of the article, the shelf date of the product, or the submission time of the comments, a clear and readable date and time format can greatly enhance the user experience.AnQi CMS as an efficient content management system, fully considers this point, and provides a flexible way to format and display these timestamp data.### Understanding Timestamps in AnQi CMS In the AnQi CMS backend, when we publish articles, products, or perform other content management operations

2025-11-08

How to implement conditional judgment in AnQiCMS template to control the display of content?

In AnQi CMS template design, flexibly controlling the display of content is the key to building dynamic, responsive websites.Whether it is to display different information based on page type, data status, or specific conditions, conditional judgment is an indispensable tool.The AnQiCMS template engine provides an intuitive and powerful conditional judgment mechanism, allowing you to easily implement these complex logic.### Core Grammar: The Basics of Conditionals The condition judgment in AnQiCMS templates is similar to many mainstream template engines, using the `{% if ... %}` tag structure

2025-11-08

How to use a for loop to traverse data and display it in the AnQiCMS template?

AnQiCMS with its flexible and powerful template system makes content display efficient and expressive.For website operators and developers, mastering how to traverse and display data in templates is a key step to unlocking their powerful features and bringing the website content to life.Today, let's delve into how to use the `for` loop in AnQiCMS templates to easily present your dynamic data.AnQiCMS's template engine adopts syntax similar to Django, which allows users familiar with other mainstream template languages to quickly get started.

2025-11-08

How to use AnQiCMS filters to truncate or convert text to uppercase and lowercase?

AnQiCMS provides powerful flexibility in content display, its template engine is built-in with a rich set of filters, helping users to easily process text without modifying the original content, including truncation and case conversion.These filters make the presentation of front-end content more accurate and beautiful, meeting the display needs of different scenarios.In AnQiCMS template syntax, the use of filters is very intuitive.You can apply a filter by adding a pipe symbol (`|`) after the variable name, if the filter requires parameters, then use a colon (`:`) after the filter name

2025-11-08