What is the basic usage method of the AnQiCMS friendship link tag (linkList)?

As an experienced website operations expert, I fully understand the importance of friend links in the website ecosystem.They are not only potential entry points for external traffic, but also an indispensable part for enhancing the authority of the website and improving search engine rankings (SEO).AnQiCMS as a highly SEO and user experience focused content management system, naturally provides an intuitive and powerful management tool for link exchange.Today, let's delve deeply into the friend link tag in AnQiCMS——linkListThe basic usage method of ——.

When you need to display friend links on the website front-end, AnQiCMS provides a namedlinkListThe dedicated template tag. Its core function is to pass all the friendship link data meticulously configured in the background to the front-end template in an easy-to-handle variable form, allowing you to flexibly control their display method.

linkListcore function and basic usage of the tag

linkListTags will collect the background friend link data into a variable, usually we will name itfriendLinksBut this is not mandatory, you can also name it with your own preference, for examplelinksorexternalLinks. Since friendship links are usually displayed in a list format, we need to use the loop structure of the template engine to present these data one by one.

Let's understand through a typical code example.linkListThe practical application:

{% linkList friendLinks %}
{% if friendLinks %}
<div class="footer-links">
    <h3>友情链接</h3>
    <ul class="friend-list">
    {% 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 %}

This code first goes through{% linkList friendLinks %}The tag retrieves friend link data and assigns it tofriendLinksThe variable. Subsequently, a{% if friendLinks %}Ensure that the relevant HTML structure is rendered only when there is a friendship link, to avoid the page appearing empty.

In the loop, we use{% for item in friendLinks %}Traverse each friendship link. HereitemRepresents the single friendship link object currently in the loop, it contains the following key fields, which can be called in the template:

  • item.TitleThis is the display name of the friendship link, for example, 'AnQi CMS Official Website' or 'Excellent Blog'. This is the link text that users see on the website.
  • item.LinkThis points to the complete URL address of the friendship link, for examplehttps://en.anqicms.com/When the user clicks the link, they will be redirected to this address.
  • item.RemarkThis is the remark information of the friend link, which is usually not directly displayed on the front-end, but can help you better identify and classify links in the back-end management.
  • item.NofollowThis is a very important SEO attribute. Whenitem.NofollowThe value is1it indicates that the link is set torel="nofollow", telling search engines not to follow this link or pass on any authority. If the value is0Or not existing, it means it is a normal link. In the above example, we cleverly use conditional judgment{% if item.Nofollow == 1 %}to dynamically addrel="nofollow"Property.

Flexible parameters: Multi-site call

in most cases,linkListThe label does not require any additional parameters to meet your needs. It will automatically retrieve all the friendship links configured in the background of the current site.However, if you are operating a multi-site AnQiCMS environment and need to call the friend link data across sites, then you can usesiteIdThe parameter is used to specify the ID of the target site. For example,{% linkList friendLinks with siteId="2" %}It will retrieve the list of friend links for the site with ID 2. This provides great flexibility for multi-site operations.

Seamless connection between backend management and frontend display

All these links' addition, editing, and management are performed in the AnQiCMS backend under the 'Function Management' menu and the 'Friend Links' module. Here you can set the title, URL, notes, and whether to add each linknofollowProperty. The intuitive operation on the back-end ensures that you can easily maintain these important external resources, while the front-endlinkListtags are responsible for safely and efficiently presenting this data on your website.

Rational utilizationlinkListTags can not only effectively improve the SEO performance of the website, but also provide users with more valuable external resources, enhance the authority and user stickiness of the website.Place it in the website footer, sidebar, or a dedicated 'friend links' page, and it can effectively play its role.By using the powerful template engine of AnQiCMS, you can customize a unique display effect for the friend links according to the overall design style of the website.

Frequently Asked Questions (FAQ)

How to add and manage friend links in AnQiCMS backend?

You can log in to the AnQiCMS backend and find the 'Function Management' menu through the left navigation bar. Click on the 'Friend Link' option in the submenu. After entering the Friend Link management page, you can click the 'Add Friend Link' button to add a new link, or edit, delete existing links, and set the title, URL, remarks, and whether to use for each link.rel="nofollow"Property.

2. Why is my friend link not showingrel="nofollow"?

Is my friend link showing?rel="nofollow"The attribute depends on whether you have checked the corresponding option when editing the link on the AnQiCMS backend. At the template level,linkListTags provideditem.Nofollowthe field has a value1(When selected as nofollow), you need to use conditional judgment in the template code (such as{% if item.Nofollow == 1 %} rel="nofollow"{% endif %})to dynamically output this property. If it is not checked on the backend, or the corresponding judgment logic is not written in the template,nofollowthe property will not be displayed.

3. Can I display the website logo or icon in the friend link list?

linkListThe fields provided by the default tags includeTitle/Link/RemarkandNofollowThere is no field directly provided for Logo or icon. If you want to display a Logo, there are usually two implementation methods:

a. **在链接标题中包含 `<img>` 标签:** 在后台添加友情链接时,直接将Logo的 `<img>` 标签代码写入“链接名称”字段。例如:`<img src="/path/to/logo.png" alt="AnQiCMS"> AnQiCMS官网`。这种方式简单直接,但后台管理界面可能显示为HTML代码。
b. **利用备注字段或自定义字段:** 在后台友情链接的“备注”字段中填写Logo的URL,或者如果AnQiCMS支持为友情链接模型添加自定义字段,您可以添加一个专门用于Logo URL的字段。然后,在前端模板中,您可以解析 `item.Remark` 或自定义字段的内容来显示图片。这需要一些额外的模板处理逻辑。