Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
In one of my website page, I use an ajax call to get JSON data (similar to what is described in this page).

Unfortunately it didn't work directly because the the return JSON data is appended with the footer
Code: Select all
<!-- Page generated by CouchCMS - Simple Open-Source Content Management -->
which make the JSON parser to fail. Indeed this is a HTML comment that is not recognized by the JSON parser.

Looking at the code, I saw this was added when one has no paid license. So to solve this issue, I had to modify the file couch/cms.php (line 331) like this:
Code: Select all
if( !K_PAID_LICENSE && ($content_type != "application/json")){
    $html .= "\n<!-- Page generated by CouchCMS - Simple Open-Source Content Management";
    $html .= " -->\n";
}
I have no problem with having a footer appended to all pages as I didn't (yet) pay the license. I think this leads to a non functional website when JSON data is involved and so I wanted to highlight it.

By modifying the core file, I hope I don't violate the open source license...

Olivier
It happens, because you generate html content. You should tell Couch to generate json content by placing appropriate tag.
Code: Select all
<cms:content_type 'application/json'/>

Forum has samples of json templates viewtopic.php?f=4&t=10578#p26379
Alternatively, use following trick with 'cms:abort' viewtopic.php?f=4&t=10609&p=26568#p26568
Thanks for the trick @trendoman!

I confirmed I put the 'cms:content_type' in the couch template, but this has no influence on the footer message...

I still believe there should be an exception in the core code since the JSON standard doesn't support any comment.
Thanks, I have proposed some change in code to @KK in GitHub.
5 posts Page 1 of 1

Who is online

In total there are 2 users online :: 1 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: MiB and 1 guest