Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
A quick question before I say "yes" to a cient! It is about feeds of data into Couch ... I've looked at the topic on RSS feeds and it seems to be about outputting a data feed from Couch. I am hoping that an Events listing page on a Couch website can be supplied with data from a .json file - is that possible?

And I wonder if it would be possible to have both a .json file and cloned pages as input for display on an Events page?
potato wrote: A quick question before I say "yes" to a cient! It is about feeds of data into Couch ... I've looked at the topic on RSS feeds and it seems to be about outputting a data feed from Couch. I am hoping that an Events listing page on a Couch website can be supplied with data from a .json file - is that possible?

And I wonder if it would be possible to have both a .json file and cloned pages as input for display on an Events page?

Are you planning to use tags from this concept (cms:calendar, cms:weeks)? http://docs.couchcms.com/concepts/events-calendar.html These tags (as well as cms:archives) rely on existing cloned pages for good (guaranteed publish_date presence, at least).

If planned event list is less 'deep' and just includes a list of cloned pages without couch-powered aggregators - then it will be possible to output a cocktail from both couch-managed template and outside json file. I now think of a single joined array (json output from cms:pages + external json) which can be re-sorted with a slight touch of php.

Aren't those external events by any chance related to the website itself? If so, there is a way to create necessary missing cloned pages (events) taking data from external source - with cms:db_persist tag. And having all events in a single template - use firstly mentioned concept of Events Calendar.
thanks for your reply @trendoman - I am not planning on using cms:calendar, the events listing will be just that - a list of dates plus afew details. Converting the feed into cloned pages would be good because it'll then be possible to display UPCOMING and PREVIOUS events.

I can't quite get my head round how Couch will get hold of the .json feed of data. And when a new date is added to the feed - how does that get picked up and added to the existing cloned pages of events.php?!? Slightly bemused by the concept of this - not sure there is a working example anywhere on the forum/docs :?
About this json source - does it happen to be online? I'd like to take a look if it's possible.

I advise to also create a function that keeps track of last json fetch and does refresh json after a period of time (whenever admin or visitor or cron script visits the site). It can have a date check which compares 'today' with last fetched json modification date. Therefore it is a good idea to create a variable in a global template to store last fetch date or, instead, cache the json on disk with KK's cms:write tag and write a cms:func to get last modification date from the file on disk.

the events listing will be just that - a list of dates plus afew details. Converting the feed into cloned pages would be good because it'll then be possible to display UPCOMING and PREVIOUS events.

Listing upcoming or previous events doesn't require them be in cloned pages. A date comparison should be enough. However it won't hurt of course to have events in database - if client decides to show archives - how many events were held past November, for example.

how Couch will get hold of the .json feed of data

If I were tasked with such a feature, I would try use my function - <cms:call 'remote_url' /> - see "Example 2. Show latest 5 commits for CouchCMS repo on GitHub" here viewtopic.php?f=8&t=11368&start=10#p30228 That example is reading json response from GH and outputs part of it. Latest updated version is on my github https://github.com/trendoman/utility-fu ... aster/curl

And when a new date is added to the feed - how does that get picked up and added to the existing cloned pages of events.php?

Since we have gathered json from a previous step, now there must be a script which compares events from json to events already in database. Simplest way is to iterate over events from json and search each in database. I can not tell you exactly how to build iterator because I have not seen the exact json, but it will be with cms:each and using multi-value variables aka arrays Concept viewtopic.php?f=5&t=10892. Add event in case it is not found by using <cms:no_results > -
Code: Select all
<cms:set event_name = 'xyz' />
<cms:pages paginate='1' limit='1' page_name=event_name skip_custom_fields='1' show_future_entries='1' show_unpublished='1' >
    <cms:no_results>
        <!-- Here create cloned page with cms:db_persist -->
    </cms:no_results>
</cms:pages>


If you can afford extra hands on this job, PM me and I'll gladly work on the script.
4 posts Page 1 of 1
cron