We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I've setup a MIGX TV to record some files related to docs. Then I can use getImageList snippet (providing along with MIGX TV package), and those just work well. Moreover, I want to update this tv to use with FileDownload R snippet (for download count and path hiding function). I've tried and it works somehow, but there're some issues on the migration.

    When using getImageList, it'll parse the certain values to a chunk named: FileChunk, which will serve display:[[+file]] and [[+title]] placeholders as a hyperlink.
    In this FileChunk, I can use FileDownload snippet to do some hiding and counting jobs:
    [[!FileDownloadFile?&getFile=`[[+file]]`]]
    And it works well as above.
    At the moment, it does show the link, but I want to custom the <a>text</a>, which "text" should be replaced by [[+title]] and [[+count]], not the current [[+filename]] instead.
    I've tried using tplCode and FileDownload with tplRow but nothing helped. Using tplCode makes the TV failed to show on the page(event a simple hyperlink). And FileDownload with tplRow cant help with inserting [[+title]] placeholder in.
    I hope someone can help me solve this, I'm really appriciated.
    PS: If you want the config of MGIX for files, then post request in this thread, I'll give you the code.
      • 30672
      • 180 Posts
      hi nepheus,

      it's been a year since you post, but perhapse you're still on modx smiley
      i'm in the same situation you describe.
      did you find a solution ?
      would it be possible for you to share it ?

      thanks !
      • if the [[+title]] comes from getImageList, you need to place the FileDownloadLink in the getImageList's row template to get its placeholders, and use &tplCode
          Rico
          Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
          MODx is great, but knowing how to use it well makes it perfect!

          www.virtudraft.com

          Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

          Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

          Maintainter/contributor of Babel

          Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.
        • Hi,
          I forgot that I opened this post. Sorry for my low responsibility of this post. I decided to roll my own solution by pure mgix tv and write a snippet to get file.

          I'll share with you if you need the same features for your project:

          fileList TV:
          Form tabs:
          [
          {"caption":"File info", "fields": [
              {"field":"name","caption":"Title"},
              {"field":"description", "caption":"Description", "inputTV":"richtextTV"},
              {"field":"filepath", "caption":"Path", "inputTV":"fileTV"},
              {"field":"dcount", "caption":"Download Count", "inputTV":"downloadcount"}
          ]}
          ]


          Grid Columns:
          [
          {"header": "Name", "width": "160", "sortable": "true", "dataIndex": "name"},
          {"header": "Path", "width": "50", "sortable": "false", "dataIndex": "filepath"},
          {"header": "Download Count", "width":"50","sortable":"true","dataIndex":"dcount"}
          ]


          Remember create some relevant TVs: richtextTV (richtext type TV), fileTV (file type TV), downloadcount(number type TV)

          getFileTV
          http://www.tipiweb.tk/getFileTV.txt


          file.item.tpl chunk:

          <li><a href="[[~ID of your resource which contains getFileTV]]&res_id=[[*id]]&item_id=[[+MIGX_id]]" target="_blank"><i class="icon-file dim"></i> [[+name]] ([[+dcount]] downloads)</a></li>


          getFile resource
          Content: [[!getFileTV]]

          In your Template list the files by using getImageList:
          [[*fileList:notempty=`<h4>Attachment Files</h4><ul class="file-list">[[!getImageList? &tvname=`fileList`&tpl=`file.item.tpl`]]</ul>`]]

          Then it's all set. When creating a resource, you should see the TV for adding attachment files to your resource.
          On frontend, you have the list of attachment, click the link will redirect you to the download page and trigger the download.

          Good luck. [ed. note: nepheus last edited this post 11 years, 4 months ago.]
          • I'm finding that I prefer to use MIGXdb to manage sets of static resources for file downloads. Set the static resources to the appropriate type (which you will need to create in System -> Content types) and set them to not show in the Tree. Then you can simply use Wayfinder or any other listing snippet to list them. Clicking on the link will open the download dialog or whatever you have your browser configured to do with the files; doc files might get opened in Word for example.

            One advantage to this is that the file URL will be for the resource, not a direct link to the file itself; in fact the path to the static resource's file can be outside of the web root. Another advantage is that these "hidden" resources can have all the fields of resources, so you can use tagging and other search functionality such as some text in the introtext or a pagetitle, longtitle or description for searching.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
            • Hi sottwell,
              I haven't tried out MIGXdb yet because I think it's still not stable when I was requested to work on attachments for resources.
              If you have time can you share how you work on MIGXdb?

              However, I think I was overused the static resource for downloads when the number is getting on. And in my solution, we also don't expose the file path, I use the rough download way (header) to output the file to browser. The file type is automatically added instead of html, based on the file name extension.
              Thanks. [ed. note: nepheus last edited this post 11 years, 4 months ago.]
              • I haven't settled on a specific method yet, so far each time I've done it differently. But it's all generally based on the information from the MIGXdb tutorials.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                • I've edited the post above, hope you understand what I mean.
                  • Yes, if you have a lot of download files using resources, even when they are hidden from the Resource Tree, could be too much.

                    The site I'm working on now where I'll be using this method has a strong emphasis on search, and a lot of .pdf files which are a pain to provide a search function for. By using static resources for these I'll be able to provide a much more comprehensive search function.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org