Get files from selected folder in TYPO3 custom extension

Viewed 22

I have created a field to select the folder using Flexform in my custom extension. But I am unable to display all the files inside that folder. Does anyone know about this? Please help. Here is my code to add a field for selecting the folder in Flexform.

<settings.path>
    <TCEforms>
        <label>LLL:EXT:file_list/Resources/Private/Language/locallang_flexform.xlf:filelist.path</label>
        <config>
            <type>input</type>
            <renderType>inputLink</renderType>
            <size>48</size>
            <eval>trim</eval>
            <fieldControl>
                <linkPopup>
                    <options>
                        <blindLinkOptions>page,url,mail,spec,file,telephone</blindLinkOptions>
                        <blindLinkFields>class,target,title,params</blindLinkFields>
                    </options>
                </linkPopup>
            </fieldControl>
        </config>
    </TCEforms>
</settings.path>

setup.typoscript:

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:spt_gallerymanagement/Configuration/TypoScript/DataProcessors/Processors/FilesProcessor.typoscript">
plugin.tx_sptgallerymanagement_sptgallerymanagement {
    view {
        templateRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Templates/
        templateRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.templateRootPath}
        partialRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Partials/
        partialRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.partialRootPath}
        layoutRootPaths.0 = EXT:spt_gallerymanagement/Resources/Private/Layouts/
        layoutRootPaths.1 = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.view.layoutRootPath}
    }
    persistence {
        storagePid = {$plugin.tx_sptgallerymanagement_sptgallerymanagement.persistence.storagePid}
        #recursive = 1
    }
    features {
        #skipDefaultArguments = 1
        # if set to 1, the enable fields are ignored in BE context
        ignoreAllEnableFieldsInBe = 0
    }
    mvc {
        #callDefaultActionIfActionCantBeResolved = 1
    }
}
# these classes are only used in auto-generated templates
plugin.tx_sptgallerymanagement._CSS_DEFAULT_STYLE (
    textarea.f3-form-error {
        background-color:#FF9F9F;
        border: 1px #FF0000 solid;
    }
    input.f3-form-error {
        background-color:#FF9F9F;
        border: 1px #FF0000 solid;
    }
    .tx-spt-gallerymanagement table {
        border-collapse:separate;
        border-spacing:10px;
    }
    .tx-spt-gallerymanagement table th {
        font-weight:bold;
    }
    .tx-spt-gallerymanagement table td {
        vertical-align:top;
    }
    .typo3-messages .message-error {
        color:red;
    }
    .typo3-messages .message-ok {
        color:green;
    }
)

FilesProcessor.typoscript:

tt_content {
   examples_dataprocfiles =< lib.contentElement
   examples_dataprocfiles {
      templateName = Galleryview
      dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
      dataProcessing.10  {
         folders.data = settings.path
         sorting = title
         as = FileList
      }
   }
}

enter image description here

enter image description here

1 Answers

you need to use a FilesProcessor in your FLUID.

just define your FLUID variable:

  :
  dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
  dataProcessing.10 { {
    folders.data = settings.path
    sorting = title
    as = FileList
  }
  :

Then you can use a partial to render that special FLUID variable.

You might get inspired by the CE 'uploads'. Therefore inspect tt_content.uploads in your TSOB (TypoScript-Object-Browser)

Related