Mohsen Emami
Mohsen Emami

Reputation: 15

Is there a way to get contents of a file with its identifier (file path) in typoscript?

I'm using Typo3 10.4.

I want to load the contents of a text file that is stored in fileadmin directory (the storageUid = 1 and the file path is fileadmin/test.txt) in typoscript. I want to use the file path, not the sys_file Uid like in

lib.test = TEXT
lib.test.data = file:17:contents

Is there any way to do that using typoscript syntax?

Upvotes: 0

Views: 680

Answers (1)

Mohsen Emami
Mohsen Emami

Reputation: 15

I solved the problem by using FILES content object. I don't have any thoughts about the performance issues since I assume that it scans all the files in a folder rather than just loading the specific file. And, I hope that this CObject will not deprecate in the next version. :D

lib.test = FILES
lib.test.folders = PATH_TO_THE_FOLDER
lib.test.renderObj = TEXT
lib.test.renderObj {
    stdWrap.data = file:current:contents
    stdWrap.if {
      value.data = file:current:name
      equals = FILE_NAME
    }
}

Upvotes: 0

Related Questions