Content adapter page resources

I’m trying to implement a content adapter, using a local json file; each page generated from the content adapter will have between zero and five page resources. The information about the page resources is in the json, buried a few levels deep; each one has two lines in the json: a UID, which is the file name, and a “tag” which describes the image context.

I’ve been able to get the content adapter working, but I’m struggling with the page resources. I need to traverse the json to get the file name of each image, and won’t know ahead of time what that file name will be for a given page resource (since there may be several for a single page), and need to print the associated tag with the image. The Content adapters docs seems to assume I’ll know the file url/it will be consistent from page to page.

The repo is public: GitHub - Brown-University-Library/u2 at proto/ees · GitHub . The json is at /assets/data.json, the various images are also in assets; the content adapter is at /content/kiosk/_content.gotmpl; the page layout is at /themes/starter/layouts/kiosk/page.html.

As a side note, in this content adapter, is there a way to have the information from the json in a different variable from the page params? I’d like to be able to print all the json data in a loop, without the kind/draft/date info being included.

Before spending any time on the details of your request, why do the images need to be page resources? If you write the image data to front matter you can access the images from templates (e.g., page.html) as global resources with resources.GetMatch.

They don’t, I just didn’t see a way in the docs to add a global resource and it therefore didn’t occur to me! I’m not sure I understand how I would get there in the content adapter, though.

The images are already global resources… they are in the assets directory.

::facepalm:: Right, obviously. My bad.

So am I remarsheling the data from the json file that’s been unmarsheled? And then, I guess, traversing it in the page template?

Within the content adapter, when creating a page, create an array of images in front matter where each element of the array contains the globally unique identifier for the image, and its tag.