Back

Display a list of Items in a folder

Description

This snippet shows how to the use the macro viewtool's fileRepository method to build a list of files and folders in a folder.  This is the same viewtool that the fileRepository macro uses.  You have to get the folders and files separately. 

The objects in the lists are:

Folder Objects - http://dotcms.org/api/com/dotmarketing/portlets/folders/model/Folder.html
File Objects - http://dotcms.org/api/com/dotmarketing/portlets/files/model/File.html

Code

#set ($foldersList = $macro.getfileRepository("/demos/", "true", $request))
#set ($filesList = $macro.getfileRepository("/demos/", "false", $request))

<h2> Folders </h2>
<ul>
#foreach($folder in $foldersList)
  <li> $folder.title - $folder.path </li>
#end
</ul>

<h2> Files </h2>
<ul>
#foreach($file in $filesList)
  <li> $file.title - ${file.path}${file.fileName} </li>
#end
</ul>���