We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21112
    • 156 Posts
    Thanks! That worked. You’ve been such a great help, I appreciate it.

    As is usually the way, now that that problem is out of the way, a new one has appeared. It seems that for this ditto call, I am unable to use a second similar ditto call on the page or call a string of comma seperated document IDs as I can when calling articles.

    This is what the output looks like when one document (wb link with some custom TVs) is called (remember it’s in development, unoptimised code so it’s messy):

    <div class="filecontianer"><table width="560px" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="35px"><p class="bluebold" style="margin:0;">Type</p></td><td width="435px"><p class="bluebold" style="margin:0;">Filename</p></td><td width="70px" align="center"><p class="bluebold" style="margin:0; text-align:center;">Filesize</p></td></tr>
    <tr style="margin:0; padding:0;"><td width="35px" align="center" style="margin:0;"><img src="images/icon_word.gif" alt="Microsoft Word" title="Microsoft Word" /></td>
    
    <td width="435px" style="margin:0;"><p style="margin:0; padding:0;"><a href="/documents/events/photorules.doc">photorules</a></p></td>
    <td width="70px" style="margin:0;"><p  style="margin:0 15px 0 0; padding:0; text-align:right;">51.7 kB</p></td></tr>
    <tr><td colspan="3" style="margin:0 15px 0 0;  padding:0;"><p style="margin:0; padding:0 0 0 38px;">The Contest Rules and Entry Agreement document for the 2007 AIP photography contest.</p></td></tr>
    </table>
    </div>


    But when I use this ditto call:

    [[Ditto? &documents=`104,107` &display=`all` &sortBy=`createdon` &sortDir=`DESC` &tpl=`DittoFileTemplate`]]


    I get the following output:

    <div class="filecontianer"><table width="560px" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="35px"><p class="bluebold" style="margin:0;">Type</p></td><td width="435px"><p class="bluebold" style="margin:0;">Filename</p></td><td width="70px" align="center"><p class="bluebold" style="margin:0; text-align:center;">Filesize</p></td></tr>
    <tr style="margin:0; padding:0;"><td width="35px" align="center" style="margin:0;"><img src="images/icon_pdf.gif" alt="Adobe PDF" title="Adobe PDF" /></td>
    
    <td width="435px" style="margin:0;"><p style="margin:0; padding:0;"><a href="/documents/events/stav2008/VCEConf2008_Regform_Generic.pdf">VCEConf2008_Regform_Generic</a></p></td>
    <td width="70px" style="margin:0;"><p  style="margin:0 15px 0 0; padding:0; text-align:right;">80.7 kB</p></td></tr>
    <tr><td colspan="3" style="margin:0 15px 0 0;  padding:0;"><p style="margin:0; padding:0 0 0 38px;"></p></td></tr>1
    <tr><td colspan="3" style="margin:0 15px 0 0;  padding:0;"><p style="margin:0; padding:0 0 0 38px;">The Contest Rules and Entry Agreement document for the 2007 AIP photography contest.</p></td></tr>
    </table>


    A cesond dittle call on the same page to a different ID displays this:

    <div class="filecontianer"><table width="560px" cellpadding="0" cellspacing="0" border="0">
    
    <tr><td width="35px"><p class="bluebold" style="margin:0;">Type</p></td><td width="435px"><p class="bluebold" style="margin:0;">Filename</p></td><td width="70px" align="center"><p class="bluebold" style="margin:0; text-align:center;">Filesize</p></td></tr>
    
    </table>
    </div>


    The second document in the string is displayed, rather than the first. The line generated by the filedetails is shown without any output from the snipped, with an odd trailing "1" and ditto doesn’t display the file’s description (called from a custom template variable).

    This is getting a bit complicated, but we’re ALMOST there. If I can get an arbitrary series of documents showing correctly as a list via ditto, then I’ll be done!

    Thanks again in advance.
      • 29774
      • 386 Posts
      Hi Neil,

      yeah I came across this myself just the other day. It’s down to the way the snippet is included, it seems that something has changed with the Modx core since I wrote this snippet.

      I’ve got a new version which will generate a file archive using Ditto in the same way that Reflect does, ie it runs Ditto from Filedetails rather than the other way round. Want to try it out? You can now output an archive of files like this:

      [!FileDetails?archive=`TRUE` &tpl=`chunkName` &dittoSnippetParameters=`parents:69|sortBy:menuindex|sortDir:ASC` !]
      


      And you can use the following placeholders in your template:
          [+filetitle+]	 	- file title (pagetitle field)
          [+filename+]		- file name (the physical file name)
          [+filesummary+] 	- file summary (introtext field)
          [+filelink+] 		- link to the file
          [+fileicon+] 		- file icon
          [+filesize+] 		- file size
          [+filedate+] 		- file date
      


      Remember, you need a tv called ’file’ in the documents found by Ditto, otherwsie the document will be ignored. Also, make sure the snippet is included correctly:
      <?php
      return include($modx->config['base_path'] . 'assets/snippets/filedetails/filedetails.inc.php');
      ?>
      
        Snippets: GoogleMap | FileDetails | Related Plugin: SSL
        • 7231
        • 4,205 Posts

        I’ve got a new version which will generate a file archive using Ditto in the same way that Reflect does, ie it runs Ditto from Filedetails rather than the other way round. Want to try it out?
        Sweet grin I will surely check this out. I like that Ditto is finding it’s way into other snippets making the setup easier. Thanks.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 21112
          • 156 Posts
          Thanks therebechips! That did the trick! It works almost exactly as it should now! The only problem I have remaining is that the [+filesummary+] seems to be completely ignored. The space where it is put into the template is simply empty in the output html./ I’ve spent about 3 hours checking to make sure I’ve done everything correctly and to try and find any possible conflict, but I’m coming up empty. Can you double check the new code for me to make sure it’s working as it is supposed to?

          Thank you!
            • 29774
            • 386 Posts
            @neilcreek

            You have some text in the Summary (introtext) field right? It should be working, but you could try this:

            Change line 150 of filedetails.inc.php to:
            $itemTemplate = "@CODE: [+file+][+introtext+]"; 
            
              Snippets: GoogleMap | FileDetails | Related Plugin: SSL
              • 21112
              • 156 Posts
              That did it!! Thank you so much! Everything seems to be working now! It’s a great relief, and I really appreciate the help smiley
                • 20648
                • 26 Posts
                I’m trying to get this snippet to work.
                The single file call is working perfectly, but not the file archive call.
                I have created the TV and named it "file", and assigned it to the right template. I have created the documents for each file and choosed a file for the file tv field.

                This is my call for the document that has ID 36. The call is placed inside that document (in the document content field).
                [!FileDetails?archive=`TRUE` &tpl=`markedsmateriell` &dittoSnippetParameters=`parents:36|sortBy:menuindex|sortDir:ASC`!]

                I get the filetitle, filesummary and filelink to work. But fileicon, filesize, filename and filedate is blank.

                This is my template "markedsmateriell":

                <div class="divider">
                <h4> <a href="[+filelink+]" title="download [+filename+]">[+filetitle+]</a></h4>
                <p>[+filesummary+]</p>
                <p>[+fileicon+] <a href="[+filelink+]" title="download [+filename+]">[+filename+]</a> [+filesize+] | [+filedate+]</p>
                </div>

                I have been spending several hours trying to figure out why this isn’t working. Am I missing something? If anyone can help me...
                  • 29774
                  • 386 Posts
                  Hi Murias,

                  can you check that you are including the snippet like this:
                  return include($modx->config[’base_path’] . ’assets/snippets/filedetails/filedetails.inc.php’);

                  Also, what version of Ditto are you using?

                  Thanks
                    Snippets: GoogleMap | FileDetails | Related Plugin: SSL
                    • 20648
                    • 26 Posts
                    Thank you for your reply, therebechips.
                    I figured it out. There was nothing wrong with either the snippet or my config. The only thing I didn’t check was actually the address to the file. Stupid me! One backslash in the file address did the trick. It’s working like a charm now. Thank you for this handy snippet. I’m using it for an intranet site with lots of novice users. I’m using the snippet for a downloading service of div files. The snippet is so self explaining, that even the most novice user can understand and use it. And at the same time it’s also a very easy and timesaving file management system for me too smiley.
                      • 29774
                      • 386 Posts
                      Very pleased you worked it out! Good luck with your project.
                        Snippets: GoogleMap | FileDetails | Related Plugin: SSL