Discussion:
[TYPO3-english] Listing files and folders with TYPO3 extbase fluid?
Dmitry
2018-03-06 14:43:27 UTC
Permalink
I have files array like

'file1.pdf',
'file2.pdf',
'file3.JPG',
'Folder1/file1.pdf',
'Folder1/Subfolder1/Subfolder-file1.txt',
'Folder2/text.txt',
'Folder2/file2.pdf'

For get list of files and folder I use following fluid

<f:for each="{files}" as="userFile">
<f:if condition="{userFile -> myext:explode(delimiter:'/') -> f:count()} == 1">
<f:then>
<a href="{userDirectory}{userFile}" target="_blank">{userFile}</a><br />
</f:then>
<f:else>
<div class="folder">
<f:for each="{userFile -> myext:explode(delimiter:'/')}" as="segment" iteration="itemIteration">
<f:if condition="{itemIteration.isFirst}">
<f:then>{segment}</f:then>
<f:else><a href="{userDirectory}{userFile}" target="_blank">{segment}</a><br /></f:else>
</f:if>
</f:for>
</div>
</f:else>
</f:if>
</f:for>

And I get only list files and folders

<a href="">file1.pdf</a>
<a href="">file2.pdf</a>
<a href="">file3.JPG</a>
<div class="folder">Folder1</div>
<a href="">file1.pdf</a>
<div class="folder">Folder1</div>
<a href="">Subfolder1
<a href="">Subfolder-file1.txt</a>

<div class="folder">Folder2</div>
<a href="">text.txt</a>
<div class="folder">Folder2</div>
<a href="">file2.pdf</a>

How I can get listing like with fluid? Is it possible?

<a href="">file1.pdf</a>
<a href="">file2.pdf</a>
<a href="">file3.JPG</a>

<div class="folder">Folder1</div>
<a href="">file1.pdf</a>
Subfolder-file1.txt
<a href="">Subfolder-file1.txt</a>

<div class="folder">Folder2</div>
<a href="">text.txt</a>
<a href="">file2.pdf</a>
--
Kind regards,
Dmitry Vasilev
www: http://typo3.ru.net/
Skype: thule-varahi;
Phone: +7 950 001 85 15
Loading...