Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using Zendesk API for article in multiple sections
// fix to display general questions in themes' sections
// using Zendesk API
// @link https://developer.zendesk.com/rest_api/docs/help_center/articles#list-articles
(function() {
if ( $( '.breadcrumbs a[href*="200506781"]' ).length ) { // 200506781 is ID of the section for general questions
var config = {
$articleList: $( 'ul.article-list' ),
tmpl: _.template( '<li><a href="<%= url %>"><%- title %></a></li>' ),
apiUrl: 'https://proteusthemes.zendesk.com/api/v2/help_center/sections/200132421/articles.json',
};
var appendArticles = function( data ) {
_.each( data.articles, addArticle );
};
var addArticle = function( article ) {
config.$articleList.append( config.tmpl( {
title: article.title,
url: article.html_url,
} ) );
};
$.get( config.apiUrl, '', appendArticles );
}
})();
// hide dummyhide articles - if section has 0 articles fix
(function() {
$( '.article-list a[href*="dummyhide"]' ).parent().remove();
})();
@kalico1

This comment has been minimized.

Copy link

@kalico1 kalico1 commented Aug 14, 2015

This is really exciting...would love to test it out. You mentioned writing a tutorial....any timeline for getting that done? I think I can piece it together from what you've said, but....stuff happens. ;-)

@starr321000

This comment has been minimized.

Copy link

@starr321000 starr321000 commented Aug 18, 2015

HI Primoz,

Thanks very much for putting this together. Wondering if you might have time for a question? I am getting an "Unexpected token ILLEGAL" error on line 8 when trying to implement it with my Zendesk instance. Any ideas what the issue could be?

Thanks,
Starr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.