#1 2016-05-10 20:30:11

werd
Member
From: Riga, Latvia
Registered: 2016-05-09
Posts: 7

Custom endpoint to expose page articles in JSON format

Hi,

I have a blog page. In blog page I need to load blog posts(articles) via Ajax request for current language. Data must be exposed in JSON e.g:

{
  "posts":[
    {
      "category":"Ideas", // First category name in current language
      "title":"Lorem ipsum", // Article title in current language
      "text":"Sometimes small things lead to the biggest breakthroughs.", // Article content in current language
      "image":"http://site.com/files/image.jpg", // First media URL in current language
      "date":"May 1st 2016", // Date in current language
      "link":"http://site.com/en/blog/article-xy" // URL in current language
    },
    ...
  ],
  "load_more":true // Whether there is a next page or not
}

How can this be done? The main question is how to retrieve data in the same manner as I would get using Ionize tags - <ion:page:articles>...

Last edited by werd (2016-05-10 20:32:22)

Offline

#2 2016-05-11 13:00:53

otemu
Member
Registered: 2014-03-07
Posts: 183

Re: Custom endpoint to expose page articles in JSON format

Hi,

Your need to use a module for this, probably passing the current pageid as a parameter and then return all the articles in json format, retrieving this data in the same manner as ionize tags will take some analyzing of there code or you could write your own custom queries if you find that more easier to achieve.

If you are going to attempt to use existing ionize code I probably say look at
application/libraries/Tagmanager/Page.php and application/libraries/Tagmanager/Article.php
Also look at there models 'article_model', 'page_model', 'url_model

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations