Read json file from DCE Fluid template

203 views Asked by At

I have a file collection with LibreOffice Documents. For every Document there is metadata file in json format with same file name.

I building a DCE that iterates through the file collection and shows links to Documents and the metadata of.

So I want to read the json string from the accompanying json file, because Format / Json / DecodeViewHelper takes a json string.

I can't find any viewhelper, that extracts a string from a given text file. Do I have to write a custom viewhelper that takes a file reference and spits out the containing string?

thanx in advance,

siepmannj

1

There are 1 answers

0
Rudy Gnodde On

There is no default ViewHelper for reading the content of a file and returning it. You could however do this with TypoScript and the f:cObject ViewHelper.

Your TypoScript would be something like:

lib.readfile = FILE
lib.readfile.file.current = 1

And in your template:

<f:cObject typoscriptObjectPath="lib.readfile" data="path/to/file" />