We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29774
    • 386 Posts
    This is an auto-generated support/comment thread for FileDetails.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Grab the file size, date modified and file icon for a file.
      Snippets: GoogleMap | FileDetails | Related Plugin: SSL
      • 23703
      • 180 Posts
      When using this snippet as per instructions here I get this error:
      Fatal error: Cannot redeclare formatbytes() (previously declared in W:\www\manager\includes\document.parser.class.inc.php(729) : eval()'d code:59) in W:\www\manager\includes\document.parser.class.inc.php(729) : eval()'d code on line 77

      I get the error when &summarize > 1 in the Ditto call.

      If I limit the Ditto call to one item it works, but I get no output at all. The snippet returns nothing. I have traced this to the setting of the output template.
      In line 28 the snippet checks if there is a specified template chunk in the snippet call. If not, it uses a default one.
      28   $tpl = isset($tpl)? "$tpl" : '[+icon+] [+size+] | [+filedate+]';

      In line 45 the snippet tries to set the template to a template chunk regardless of if a chunk is specified or not. If no chunk is specified this causes a blank (nonexistent) chunk with no placeholders to be used.
      45   $tpl = $modx->getChunk($tpl);

      I suggest changing the line 28 to this
      28   $tpl = isset($tpl)? $modx->getChunk("$tpl") : '[+icon+] [+size+] | [+filedate+]';

      and removing line 45 completely.
        • 29774
        • 386 Posts
        Thanks Pont, I have updated the snippet to 1.1 with your fix.
          Snippets: GoogleMap | FileDetails | Related Plugin: SSL
          • 29774
          • 386 Posts
          Updated to version 1.3 with support for outputting multiple file details.
            Snippets: GoogleMap | FileDetails | Related Plugin: SSL
            • 8374
            • 9 Posts
            Hello, I did some fixes, namely:

            - the file TV can be named any name (specified by snipplet paarmeter)
            - in my version of Modx (0.9.6.3), the files are saved as "assets/..." not "/asstes/...", which makes the FileDetails snipplet to fail in finding filedetails.

            Simple fixes, but if you are interested, I could send you either the whole new file or a patch produces byt BZR.

            Thanks alot for the work!
            Martin
              • 5515
              • 4 Posts
              Hi,

              Is it possible to format the first document/row in FileDetails like ditto does with tplFirst or maybe using PHx?

              I tried using the ditto parameters but with no luck, one example of that is:

              [!FileDetails?archive=`TRUE` &dittoSnippetParameters=`parents:5|sortBy:editedon|sortDir:ASC|tplFirst:fileDownload-first` &tpl=`fileDownload` &outerTpl=`table` &dtFormat=`F d, Y`!]


              I also tried using phx:firstlast, and kept getting alpha on all rows.

              <tr id="[[phx:firstlast]]" class="file-post">
              <td class="file-icon">[+fileicon+]</td><td class="file-details">
              <h3><a href="[+filelink+]">[+filetitle+]</a></h3>
               <div class="publish-info" >[+filedate+]</div>
              <strong>Description: </strong>[+filesummary+]</td>
              <td class="post-col"><a href="[+filelink+]">[+filename+] ([+filesize+])</a></td>
              </tr>


              I’m new to ModX, so I’m still learning all the possibilities and limitations. So, any assistance would be appreciated.

              Note: FileDetails 1.3.1, Ditto 2.1.0

              Thanks.

                • 29774
                • 386 Posts
                @cmatter

                Nope, sorry. However, it is possible to use FileDetails the ’other way round’: instead of using the internal Ditto call inside FileDetails (which is really just a convenience), you can use Ditto to output your list and invoke FileDetails within the Ditto row template. Make sense?
                  Snippets: GoogleMap | FileDetails | Related Plugin: SSL
                  • 5515
                  • 4 Posts
                  Well, I tried using ditto without tplfirst just to get it working and I get this message three times:
                  "&tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it."

                  Here is what I did...

                  Sample Document Structure:
                  Project Downloads (5)
                  File 1 (13)
                  File 2 (14)
                  File 3 (15)

                  Project Downloads (5) content:
                  <table>
                  [[Ditto? &startId=`5` &display=`all` &paginate=`0` &tpl=`FileDetailsDitto_tpl` &sortBy=`editedon` sortDir=`ASC` &dateFormat=`%B %d, %Y`]]
                  </table>


                  Chunks

                  FileDetailsDitto_tpl:
                  [!FileDetails?archive=`TRUE` &tpl=`FileDetailsRow_tpl`!]


                  FileDetailsRow_tpl:
                  <tr class="file-post">
                  <td class="file-icon">[+fileicon+]</td><td class="file-details">
                  <h3><a href="[+filelink+]">[+filetitle+]</a></h3>
                   <div class="publish-info" >[+filedate+]</div>
                  <strong>Description: </strong>[+filesummary+]</td>
                  <td class="post-col"><a href="[+filelink+]">[+filename+] ([+filesize+])</a></td>
                  </tr>


                  Am I missing a step?


                    • 29774
                    • 386 Posts
                    When you use FileDetails within a Ditto template, you’re not outputting an archive, your just getting the details for the single file represented by the Ditto row template. Ditto iterates through the matched documents and calls FileDetails on each row. Therefore, omit archive=`TRUE` from the FileDetails call and instead pass the snippet the file you want to represent (your file tv), eg

                    [!FileDetails? &file=`[+myfiletv+]` &tpl=`FileDetailsRow_tpl`!]
                    


                    Cheers,

                    Mark
                      Snippets: GoogleMap | FileDetails | Related Plugin: SSL
                      • 5515
                      • 4 Posts
                      Thanks for the assist, that worked but I don’t get the file/document data now -- I do get the file path though. Nothing else has changed in the templates/chunks. I even checked my caching, just in case, but nothing good happened. Have a clue?

                      HTML output:
                      <tr class="file-post">
                      <td class="file-icon"></td><td class="file-details">
                      <h3><a href="assets/files/test.txt"></a></h3>
                      <div class="publish-info" ></div>
                      <strong>Description: </strong></td>
                      <td class="post-col"><a href="assets/files/test.txt"> ()</a></td>