Mecha CMS

Mecha CMS blog and documentation.

Feeds

Updated: Sunday, 07 August 2016

Working with RSS and JSON.

URL

https://mecha-cms.com/2016/feed/rss → RSS Feed
https://mecha-cms.com/2016/feed/json → JSON Feed
https://mecha-cms.com/2016/feed → map to `https://mecha-cms.com/2016/feed/rss`

Sorting

Page Chunk

Feeds are paginate–able, default per_page value for feed is 25:

https://mecha-cms.com/2016/feed/rss/2 → RSS Feed, page 2
https://mecha-cms.com/2016/feed/json/2 → JSON Feed, page 2

Custom per_page value can be updated publicly through query string URL:

https://mecha-cms.com/2016/feed/rss?chunk=15

Page Order

https://mecha-cms.com/2016/feed/rss?order=DESC → sort descending (default)
https://mecha-cms.com/2016/feed/rss?order=ASC → sort ascending

Page Filter

All post filtering methods as described here are acceptable:

https://mecha-cms.com/2016/feed/rss?filter=kind:2
https://mecha-cms.com/2016/feed/rss?filter=kind:2,4
https://mecha-cms.com/2016/feed/rss?filter=time:2016-01
https://mecha-cms.com/2016/feed/rss?filter=slug:lorem

Callback Function for JSON Feed

https://mecha-cms.com/2016/feed/json?callback=whatTheFunc

Here you can create a function named as whatTheFunc to handle the JSON output. Example:

<div id="container">Loading&hellip;</div>
<script>
function whatTheFunc(json) {
    var meta = json.meta,
        item = json.item,
        html = "";
    html += '<h1>' + meta.title + '</h1>';
    html += '<p>' + meta.slogan + '</p>';
    if (item !== null) {
        html += '<ul>';
        for (var i = 0, len = item.length; i < len; ++i) {
            html += '<li>';
            html += '<a href="' + item[i].url + '">';
            html += item[i].title;
            html += '</a>';
            html += '</li>';
        }
        html += '</ul>';
    } else {
        html += '<p>Not found.</p>';
    }
    document.getElementById('container').innerHTML = html;
}
</script>
<script src="https://mecha-cms.com/2016/feed/json?callback=whatTheFunc"></script>

View Demo

Donation and Email Subscription