Use external data as source for shortcode #701
Replies: 3 comments 2 replies
-
|
Thank you for the question @junedtan. @cbutcosk - do you have any feedback or input based on your work incorporating Georgia O'Keeffe Museum's Linked Art-based linked data infrastructure in the museum's recent Quire project? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the reply, @cbutcosk @Erin-Cecele ! While I get the gist of it, turns out we have a change in requirements to be more like "If that's not possible" part of my original post. It's then the php script that calls the API instead of having to do that in Quire. My follow-up question then is what is the best format that's recognizable by Quire that the script can produce? I'd imagine whatever is in the resulting file can be read by custom Quire shortcodes in order to render the corresponding template. I'm wondering how to define a global variable but it's stored in a file. maybe .yaml? .csv? After "quire new" the file then can be stored somewhere in the project folder and read in the shortcode code. |
Beta Was this translation helpful? Give feedback.
-
|
@junedtan GMTA, Scripting a dump of data is a very sensible approach. 😀 Any data file in the content dir gets pulled up into the data cascade and is available across templates, so you have a great deal of flexibility in choosing a file interface. If you follow the figure / object JSON Schemas you might not even have to implement a custom shortcode, just drop objects.yaml and figures.yaml files that would just be available for use in quire shortcodes, etc. But anyway those are just part of the project's Global Data Files in |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is the scenario below possible?
We have this shortcode:
{{< wpi-artwork id="71596" >}}
possibly with additional parameters, like so:
{{< wpi-artwork id="71596" with-catalogue="1" with-exhibitions="1">}}
This shortcode calls a GET REST API that returns a JSON. The resulting content then is fed into Quire templating structure and the real API call is done on "quire build" (doesn't have to also be called on "quire preview", as long as we can detect preview mode on the template file and output something else like "This section will be replaced by artwork info with id of 71596 on build").
If that's not possible, what about similar scenario but instead of calling API in real time we read the data from a CSV file (better still, a readable file containing a global variable definition with a certain format - JSON maybe?) that's in the project folder? The idea is to code some external script (maybe with php or something) that calls the APIs and produces a CSV or whatever compatible other formats - YAML maybe?) that is readable in the shortcode's template. The script is run separately and its output file is then copied to Quire's project folder.
I'm envisioning something like this on wpi-artwork.html:
{{$artwork = call_the_api('https://something.com/api/get-artwork/'+id-of-artwork-from-shortcode-argument);}}
or
{{$artwork = $global_array[id-of-artwork-from-shortcode-argument];}}
{{$artwork['title']}}
{{$artwork['description']}}
{{foreach ($artwork['exhibitions'] as $exhibition)}}Beta Was this translation helpful? Give feedback.
All reactions