How to list files from a folder in opencms?

mihailacusteanu

I need to create a new resource type in opencms which have 1 field. The field is for a target folder. Every time I select a folder from VFS and save the resource(xml) the formatter will render a the list of files from the specified folder.

I managed to create a jsp file which will create the list of files needed, but only with the target folder hardcoded. I don't know how to read data from the resource type(xml), which I can access using el expression.

AdrianRM

I am not sure if this works. Please try it out.

<cms:formatter var="content" val="value">
    <cms:contentload collector="singleFile" param="${value.TargetFolder.stringValue}">
        <cms:contentshow element="Title" />
    </cms:contentload>
</cms:formatter>

value is of type Map<String, CmsJspContentAccessValueWrapper>. You can check the Javadoc to see which other methods you have available.

I took the collector from: CmsDefaultResourceCollector.getSingleFile()

Another way to read XMLContent is with Java. e.g.:

<c:set var="path" value="${value.TargetFolder.stringValue}"/>
<%
  String path = pageContext.getAttribute("path");
  CmsXmlContent xmlContent = CmsXmlContentFactory.unmarshal(jsp.getCmsObject(), path);
  xmlContent.getStringValue(jsp.getCmsObject(), "Title", locale);
%>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to get list of all files from folder inside java resources folder

How to list files in a folder from inside Postgres?

How to get list files from a github repository folder using R

How to list files in folder

How to read files from folder

Python remove files from folder which are not in list

How to delete files from folder

How to get files list from public folder Laravel

How to list files inside a folder to a form and launch it from there?

How to extract files from a particular folder with filename stored in a python list?

How to copy specific files in a list from subfolders to a folder?

How to make a list of files in a folder and paste each of line from this list into *.plist via Terminal?

Copy all files from a list of folder locations

How to delete files from a folder using a list of file names in windows?

How to list files names in folder

Adding files from folder to the list in android app

how to list files in a folder using bash scripting

How to load multiple text files from a folder into a python list variable

xml files from folder into list

How to extract a specific list of files from a folder in Windows?

List files from certain folder using batch

How to fix the problem with reading text files of a list of files from a folder for creating rows of dataframe

How to copy files from multiple folders into one common folder using a defined list of files in a text file

How to list all files recursively from google drive folder to spreadsheet?

How to list files inside public folder?

Flutter How to get all files from assets folder in one List

how to list the files in your /tmp folder

How to list files under a folder using jenkins

wget - how to download list of files from CSV with custom folder structure