Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-11-02 15:31:27

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Simple counter to display file downloads

I had placed a simple counter on my homepage that counted the number of times a file was downloaded.
I recall that it was a dead simple piece of code and it worked. I deleted it but now i can no longer find it. I have a need for it. Cant recall if i found it here at Txp or elsewhere. It was not DB based as I recall.
any suggestions?


…. texted postive

Offline

#2 2018-11-02 16:34:10

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Simple counter to display file downloads


TXP Builders – finely-crafted code, design and txp

Offline

#3 2018-11-02 18:03:01

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: Simple counter to display file downloads

;-) that sounds right.

but if i want to track a particular fiel what is the syntax”?

<p>
    Downloads:
    <txp:file_download_downloads />
</p>

do i replace this with a filename? or will it count all downloads of all files in a directory?
<txp:file_download_downloads />

thanks!


…. texted postive

Offline

#4 2018-11-02 18:47:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: Simple counter to display file downloads

No, it has go within a txp:file_download_list wrapper. Without that it doesn’t know which file id to show.

For example, this will produce a link to the file with the ID# 123 with the number of downloads i brackets after it.

<txp:file_download_list id="123">
    <a href="<txp:file_download_link />">
         <txp:file_download_name />
    </a> (downloaded <txp:file_download_downloads /> times)
</txp:file_download_list>

Change the file_download_list to determine which files will be output, e.g. to output all files in the category public_downloads (you need to create that file category and assign your files to it first) use:

<txp:file_download_list category="public_downloads">

or to show the top ten file downloads by number of downloads:

<txp:file_download_list limit="10" break="li" wraptag="ol" sort="downloads desc">

and so on… You can find more inspiration in Phil’s files.txp form.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2018-11-02 19:09:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: Simple counter to display file downloads

Added a second example for possible similar requests.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2018-11-03 00:49:40

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,075
Website Mastodon

Re: Simple counter to display file downloads

thanks all! i have it (file download counter) working again


…. texted postive

Offline

Board footer

Powered by FluxBB