1

Can JSON feed data be displayed in a Craft site automatically?

I have a page: URL/asdfh3 I've been dynamically using 'asdfh3' to pull in data from the JSON feed that is associated with 'asdfh3'. This template works - BUT ONLY if an entry for 'asdfh3' already exists in craft.

Whilst this can be achieved by running a feed update using the FeedMe plugin, it isn't a satisfactory method - as the site breaks if new data is entered into JSON without a feed update in Craft (no template found).

So, how can Craft display external content without having to set up entries for each piece of external content?

1 Answer 1

1

The answer is Routing. Define a wildcard route e.g. URL/path/* Then tell it to use a particular template if that route is used.

The key thing to do (which I didn't do first time around) is: Don't duplicate the same route in a section. If you do, Craft follows the section path not the routing path and expect entries to be in the CMS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.