We can use %%comments%% to count the number of comments on a page, we can use %%children%% to count the number of children a page has, but we cannot count the number of files attached to a page.
The variable %%files%% should be implemented in live templates and the ListPages module to return the number of files attached to the page.
Apart from the obvious utility of this in general page content, we could also use this with the files module and CSS to only display a list of files if there were any there.
[[module CSS]]
.filesdiv0 {display: none;}
[[/module]]
[[div class="filesdiv%%files%%"]]
[[module files]]
[[/div]]
This is definitely useful +1, I would like to see a download counter tho. Something to hook up with the AW stats to get the number of downloads per item or page.
CEO of Icon Deposit
Take a look at me via Twitter, Dribbble, and Google +
Part of the problem with this wish is that it assumes that attachments must be uploaded to the current page. You can have an "attachment" on a different page if you are prepared to re-structure your site. My solution works using the childpages, countpages and listpages modules.
The following can be seen at my test site at http://vineyard.wikidot.com/childpages
Basically what you have to do is to have a category that holds a dataform with one attachment on each autonumbered page. So…
1) Create a page called childpages. On that page add the following:
2) Create a page called attachment:_template and on that page add the following dataform:
3) In your Site Manager -> Autonumbering of pages make the attachment category autonumbered.
4) On your childpages page press the button to add a new page in the attachment category (using the dataform) and upload an image. When you save the page the image will be listed in the attachments list on the childpages page and the number of attachments will have been updated to reflect the new number.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
Thanks Rob, that is an interesting workaround.
However it would be a huge pain to delete or rename attachments. You can delete the attachment page, but that leaves the file and there is no clear way to tidy up afterwards. Like the Windows registry, the file: category will grow without bound, using up site space quota.