FileDownloadR 3.0.1 Snippet FileDownloadLink placeholders not working

Hi there!

I am using FileDownloadR 3.0.1 with this snippet-call:

    [[FileDownloadLink?
    &getFile=`[[+bild]]`
    &tpl=`@CODE <a href="[[+link]]">[[+filename]] [[+count]]</a>`
    &dateFormat=`d.m.Y`
    &toArray=`0`
    &countDownloads=`1`
    ]]    

The placeholders [[+link]] and [[+filename]] are working, but [[+count]] doesn’t.

I also tried to use [[+fd.count]], which also didn’t work.

The docs for “FileDownloadLink” is telling this:

The template for this snippet is a plain href link with FileDownloadLink’s placeholders, not a chunk or a template file. If you like to see the available placeholders, just initiate the &toArray=1 parameter.

Other placeholders like [[+sizeText]] do work, it seems just the “count” isn’t working.

What am I doing wrong?

Thanks in advance,

Marc

What exactly do you mean by “not working”?
Does it output an empty string or always 0?

Also, you probably have to call the snippet uncached, so that the count value gets calculated for every page request.


I did a quick test and noticed, that the code creates duplicate entries in the database table modx_fd_paths.
Can you check this table and verify that all the rows are unique?

Hello halftrainedharry!

Thanks for your answer.

And sorry, I forgot to mention that it always outputs “0” by using “FileDownloadLink” (so for single files).

I am using this within a migx-getimagelist-call, which already is uncached:

                <ul>
                  [[!getImageList?
                    &docid=`28`
                    &tvname=`Downloads`
                    &tpl=`downloads`
                    ]]  
                </ul>

So i thought the usage of the snippet-call i posted above doesn’t need to be uncached. Though i just tested the FileDownloadLink-call uncached, which shows no difference. I also tried the opposite, meaning getImageList uncached and FileDownloadLink cached, which also shows no difference.

And yes, the code created duplicate entries in the database table modx_fd_paths as well.

Btw… by using the “FileDownload”-call (for getting folders) like this:

                [[!FileDownload?
                &getDir=`assets/downloads`
                &tplFile=`tplDownloadForm`
                &downloadByOther=`0`
                &extShown=`jpg`
                &dateFormat=`d.m.Y`
                ]]

…everything works as expected, the value of downloads gets displayed correct after having refreshed the page.

There is definitely a bug in the code.
I made this PR, that maybe fixes the issue:

1 Like

Thanks for the fix. The snippet has also to be called uncached.

Thanks for the fix! I implemented it and now it’s working as expected!

I would have not found this by myself, so really a big thanks for diving into this @halftrainedharry !