Promoted articles are a great way to present important articles in your help center. Featured articles can be used in a similar way but are more flexible because you can filter the list of articles not only based on whether or not they’re promoted, but by other properties like labels.
The example below demonstrates the use of a custom article template showing articles with one or more specific labels.
The articles can be filtered and sorted in any way you like, for example by created or updated date or on the basis of how many votes they’ve received.
By making updates to the micro-template you can change the look-and-feel of the list or add new functionality. For different article list styles that you can use with this extension, check out our article list patterns.
The featured article list is displayed using our built-in Navigation extension. You can use the options described on that extension’s page to make additional design or functional changes, regardless of whether you create the article list using attributes or JavaScript.
The example provided uses the data-element="navigation"
attribute to create a list of featured articles.
<div data-element="navigation" data-template="featured-articles" data-properties="..." data-template-data="..."></div>
To make design or functional changes you can either edit the default micro-template or replace it with one from our Pattern Library, updating the template ID if necessary.
If data attributes are used within article content you will need to ensure that the allow unsafe HTML setting is enabled within the Zendesk Guide settings.
You can create the list of featured articles using JavaScript:
<div id="featured-articles"></div>
<template id="tmpl-featured-articles">
...
</template>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
new Navigation(document.getElementById('featured-articles'), {
properties: [
"id",
"name",
"title",
"body",
"html_url",
"position",
"promoted",
"draft",
"section_id",
"category_id",
"created_at",
"label_names"
],
template: "featured-articles",
templateData: {
heading: "Featured articles",
labels: [ "a_label" ],
excerptLength: 120
}
// Additional options go here
});
});
</script>
The example above supplies the same option values to the plugin as the data-attribute example. This may be desirable if you need to fetch additional data to pass through as templateData
before rendering the list.