FileDownload R issues with path

I’m attempting to use FileDownload R with the FileDownloadLink call. No matter what I do the error log always displays the error 717 &getDir parameter expects a correct dir path. <b>""</b> is given.

The link in it’s default state works and appears on the page and allows the file to be downloaded, however with the error persisting it won’t let me add any additional parameters to the call so I can’t give it a template etc.

My call currently looks like this

[[!FileDownloadLink?
&getFile=`downloads/training/guides/pdf/theMacHealthCheckGuide/TheMacHealthCheckGuide.zip`
]]

This shows the link and allows it to be downloaded but still throws the error.

Any help here would be greatly appreciated, I’ve googled and tried to troubleshoot for a good 24 hours but haven’t gotten anywhere.

The path in getFile has to be relative to the base path of MODX (since it uses the media source 0).

You can use the default path placeholder of MODX: {base_path}, {core_path} or {assets_path}.

My tests work well on a dev machine with the following property:

&getFile=`{base_path}assets/test/test.png`

I think this error always gets output when no &getDir property is defined.
But the code should still work and you should still be able to add additional properties.


If no &getDir property is set, the value defaults to [''].

The value [''] is not empty, so the error message gets logged.

Sure enough, if I add the &getDir property and define it I no longer get the error. However even using the {} notation with base_path (not seen the curly brackets used before) I still can’t add additional properties.

So now my call looks like this:

[[!FileDownloadLink?
&getDir=`{base_path}downloads/training/guides/pdf/themacHealthCheckGuide`
&getFile=`{base_path}downloads/training/guides/pdf/theMacHealthCheckGuide/TheMacHealthCheckGuide.zip`
&tplCode=`
<div class="button-container">
      <a class="button" href="[[+link]]" download>Download the Guide here</a>
  </div>`
]]

The &tplCode never gets rendered and I just get the ‘default’ option of the filename as a link on the page itself.

I get the same result if I paste the example code from the manual page on the MODX site for FileDownloadLink but change the path to mine. I get the link but not the template code.

There exists no property tplCode.

Use the property with the name tpl.
Then either put the template code in a chunk or use @CODE (or @INLINE) at the start of the markup:

&tpl=`@CODE <div class="button-container"><a class="button" href="[[+link]]" download>Download the Guide here</a></div>`

The logging will be fixed in the next version. Only a not found path that is not empty will be logged.

1 Like

Putting it in the chunk and using the &tpl property worked. However it was not clear from the documentation that this was the case: https://docs.modx.com/3.x/en/extras/filedownload-r/filedownload-r.filedownloadlink

Thanks for getting me on track.

The documentation you linked doesn’t seem to be up-to-date.

Use this one instead:

https://jako.github.io/FileDownloadR/usage/#filedownloadlink

Thanks so much - so much clearer now!

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.