Skip to content

Instantly share code, notes, and snippets.

@tinybeans
Created July 13, 2016 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tinybeans/f47edff5cfa64ece8b709516d431ade0 to your computer and use it in GitHub Desktop.
Save tinybeans/f47edff5cfa64ece8b709516d431ade0 to your computer and use it in GitHub Desktop.
MTAppListing でブログ記事グループ的なことをやってみる(カテゴリ追加)
(function($){
// 元記事:http://bit-part.net/blog/2015/01/mtapplisting.html
$('#customfield_bpentrylist').MTAppListing({
url: '<mt:Var name="config.CGIPath"><mt:Var name="config.DataAPIScript">/v1/sites/<mt:BlogID>/entries',
data: {
limit: 9999999,
// categories を追加します
fields: 'id,title,categories'
},
jsontable: {
header: {
id: 'ID',
title: 'タイトル',
// categories: 'カテゴリ' を追加します
categories: 'カテゴリ'
},
// categories を追加します
headerOrder: ['id', 'title', 'categories'],
itemsRootKey: 'items',
listingTargetKey: 'id',
listingTargetEscape: false
},
cbProcessResponse: function(cb, response){
// Data API からのレスポンス JSON を加工します
for (var i = 0, l = response.items.length; i < l; i++) {
// categories 配列を取得し変数にセットします
var categories = response.items[i].categories;
// カンマ区切りで文字列にします
response.items[i].categories = categories.join(', ');
}
return response;
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment