In content operation, effectively highlighting and displaying important articles is the key to improving user experience and guiding traffic.AnQiCMS (AnQiCMS) understands this and therefore provides a flexible article recommendation feature that allows you to mark and accurately filter and display content on the website front-end based on its importance or specific use.
Part one: Understanding article recommendation attributes: a tool for content operation
In AnQi CMS, the recommended attributes of articles are like special tags applied to content, which are a powerful mechanism to assist in article classification, aimed at helping you quickly identify and call specific types of articles from a vast amount of content.They are not just marks on the back-end management, but also the foundation of the front-end content presentation logic.
These recommended attributes are crucial for content operation:
- Enhance the visibility of important content: Mark key articles as 'headlines' or 'slides', ensuring that users can see them as soon as they enter the website.
- Improve user browsing experience: Display 'recommended' articles or 'scrolling' news based on the user's interests or page layout to enhance the readability and attractiveness of the content.
- Support diversified content layoutDifferent recommendation attributes can correspond to different display areas, such as the focus image on the homepage, popular recommendations in the sidebar, and bold display on the list page, etc.
Anqi CMS provides a variety of preset recommendation attributes for you to choose from, each attribute corresponds to a short letter code, which is convenient for calling in templates:
- Headline
[h]This is usually used for the most important articles on the website that need immediate attention. - Recommended
[c]These are regular recommended contents that can be displayed in multiple areas. - Slide
[f]: Articles applicable to carousel or focus image areas. - Featured
[a]: Articles specially recommended, importance between headlines and recommendations. - Scrolling
[s]: Content suitable for news scrolling or notification bulletin boards. - Image
[p]: Emphasizes that the article contains high-quality images, which may be used in image topics or picture-display areas. - Jump
[j]The article link will directly jump to an external address, rather than the in-site detail page (usually set during article editing to set the jump link).
In the AnQi CMS backend, when you edit or publish articles, you can find the 'recommended attributes' option in the article editing interface.Here is the multiple choice box, you can select one or more properties according to the actual needs of the article.For example, an article that is both a 'headline' and suitable for a 'slide', you can check both of these options at the same time.
The second part: Precisely calling in the front-end template: Step-by-step implementation of filtering display
To filter and display content on the website front-end based on these recommended properties, Anqi CMS mainly relies on its powerful template tag system, especiallyarchiveListTag. This tag is the core tool for obtaining the list of articles, and through flexible parameter matching, it can realize various content filtering needs.
1. Call articles with specific recommendation attributes.
If you want to display all articles marked as 'recommended' in a certain area (such as the hot recommendations module on the homepage), you can usearchiveListlabel'sflagthe parameter.flagThe value of the parameter is set to the letter code corresponding to the attribute.
Suppose you want to get up to 5 articles marked as 'recommended':
{% archiveList recommendedArticles with type="list" limit="5" flag="c" %}
{% for article in recommendedArticles %}
<div class="card">
<a href="{{ article.Link }}">{{ article.Title }}</a>
<p>{{ article.Description|truncatechars:100 }}</p>
</div>
{% empty %}
<p>暂无推荐文章。</p>
{% endfor %}
{% endarchiveList %}
The above code will retrieve up to 5 articles with[c]Recommend articles with properties, and display their titles and summaries in a loop, while linking to the article detail page.
2. At the same time, call articles with multiple recommended properties (OR logic)
In the operation, you may need to display articles that are marked as "headline" or "slideshow", that is, as long as the article has any of these attributes, it should be displayed. At this time, you canflagIn the parameter, use commas to separate multiple property codes.
For example, display 3 articles that are both 'Headline' and 'Slideshow':
{% archiveList importantFeatures with type="list" limit="3" flag="h,f" %}
{% for item in importantFeatures %}
<div class="feature-item">
<h3><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
<span>属性:{{ item.Flag }}</span> {# 这里显示文章的推荐属性代号 #}
</div>
{% empty %}
<p>暂无重要特色内容。</p>
{% endfor %}
{% endarchiveList %}
This code will filter out the marked as[h]or[f]of the articles, and display them.
3. Exclude some recommended attributes articles
Sometimes, you may want to exclude certain recommended attributes' articles from a list area, for example, display all articles but exclude those marked as 'Headline' to avoid repetition. In this case, you can useexcludeFlagParameter.
For example, display 5 articles but exclude the "top story" articles:
{% archiveList generalArticles with type="list" limit="5" excludeFlag="h" %}
{% for article in generalArticles %}
<div class="article-summary">
<h4><a href="{{ article.Link }}">{{ article.Title }}</a></h4>
</div>
{% empty %}
<p>暂无普通文章。</p>
{% endfor %}
{% endarchiveList %}
This way, even if some articles are "top stories", they will not appear in this list.
4. Combine other filtering conditions
Recommended properties do not exist independently, you can combine them witharchiveListother parameters of the tag (such ascategoryIdlimiting specific categories,moduleIdlimiting specific models,ordersorting methods, etc.)