Created
July 13, 2016 23:20
-
-
Save tinybeans/f47edff5cfa64ece8b709516d431ade0 to your computer and use it in GitHub Desktop.
MTAppListing でブログ記事グループ的なことをやってみる(カテゴリ追加)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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