We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36818
    • 119 Posts
    Hi all,

    Using Filelister Addon (Ver. 1.1.1).

    Is it possible to list all subdirectories and files in it held in a folder defined with the path-option with one Snippet-Call?

    i.e. Wanted output

    Folder
       ->Subdir 1 
          -> File 1.1
          -> File 1.2
       ->Subdir 2
          -> File 2.1
          -> File 2.2
    


    When I understood the possibilities of Filelister right, it can list the files in one folder but not the files in subdirectories in one go.

    f.

    This question has been answered by achterbahn. See the first response.

    [ed. note: achterbahn last edited this post 14 years, 8 months ago.]
      • 36818
      • 119 Posts
      I don't want to nag, but is the behaviour that I want a feature by default of FileLister?
      Would be great if someone could give me a hint.

      all the best.
      f.
        • 36818
        • 119 Posts
        found out that with changing the lines (in FileLister Snippet)
        /** @var DirectoryIterator $file */
        foreach (new DirectoryIterator($curPath) as $file) {

        with
        /** @var DirectoryIterator $file */
        $di = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($di) as $filename => $file) {


        Recursive file listing over a given path is possible. But then it is not possible anymore to download the files. I think the generated filelink is not valid anymore.

        I placed a feature request on https://github.com/splittingred/FileLister/issues/17, but I also would apreciate help here in the forum.

        All the best.
        f.
        • discuss.answer
          • 36818
          • 119 Posts
          hm, I'm writing for myself. hope this is helpful for others with the same need...

          I got the invalid link problem solved so far.

          I changed
          $filePath = $relPath.(!empty($relPath) ? '/' : '').$file->getFilename();


          (it seemed that the $relPath is always empty)

          with
          $filePath = str_replace($path, '', $filePath);

          (this will "construct" the path necessary for the key that is generated for downloading the file.)


          and the links are working.