JSON output / Raw output templates

More
11 years 5 months ago #38605 by rubenreyes
We are currently working on a mobile app for a client for which we need to get the items of a category in a computer readable format (XML or JSON).

Similar to RSS feeds, it would be great if we could have the possibility of a configurable, raw XML or JSON output for both categories and items.

I was thinking this could be implemented by just adding some parameters to the URL, for instance:
Code:
http://domain.com/path/to/page?format=raw&type=json

Then I thought that it would be good if we could expand this to be a JSONP output by adding a callback parameter:
Code:
http://domain.com/path/to/page?format=raw&type=json&callback=myfunction

It would be great if we could select what fields are included. It would be great if I can have some custom output....

So, while I was thinking of this idea I thought of the following: what if I could assign to categories and content types one or more raw output templates? This would give us the flexibility to create new templates, we could use the structure we already have for templates where we can easily configure them through parameters, and select what fields should be displayed, and how the output should be built.

I will be happy to help with this idea. If you think it is good and easy to implement.

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #38609 by ggppdk
Currently, we have 2 layouts:
-- item = (content)
-- category = (content list, category, myitems,mcats,author and SOON tags and favourites)

you suggest one more ??:
-- category JSON or 'RAW'


NOTE: (just mentioning that along with installable content Applications these are planned for templating)
-- we decide not to add new layouts for tags/favourites views, instead:

a. tags, favourites will use the category layout content list

b. each template will allow multiple layout configurations (beside the duplicate template button we will have the duplicate configuration)


-- So, you suggest that a category besides its 'clayout' parameter which specifies a template will also have an 'jclayout' for json output when the URL variable '&type=json' is used ?

-- note currently it is possible to display a category via a different template layout by adding '&clayout=sometmpl' to the URL

so we will have also:
'&type=json' (default JSON layout of category)
'&type=json&jclayout=sometmpl' (category with 'sometmpl' JSON layout)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #38629 by rubenreyes
I didn't know about the clayout parameter. That actually solves my request completely.

What I am going to do is create a new layout in my Joomla template, for instance raw.php that will only include the following line:
Code:
<jdoc:include type="component" />

And then use the clayout parameter in FC to get the output generated in the format I need.

Thank you so much!

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #38631 by ggppdk
Hello,
ok but also instead of just

&clayout=mobile2

you could use (as you suggested before yourself):

&clayout=mobile2&tmpl=component
OR
&clayout=mobile2&format=raw

-- so, do you really need the raw.php for Joomla template ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #38636 by rubenreyes
I really need raw.php in the joomla template to remove all the HTML code that I don't need.

raw.php will have only <jdoc:include type="component" />

and that will be directly the output from my json Flexicontent template...

I will work on it and send you the files so that you can test it.

Please Log in or Create an account to join the conversation.

More
11 years 5 months ago #38639 by rubenreyes
Ok, we have developed it... works perfectly!

Take a look here and feel free to include in your official release:

github.com/Lyquix/flexicontent_templates

Sample category:



Sample item:

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.379 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline