On Monday 04 February 2008, Domagoj Babic wrote:
> I'd like to track how often are files with certain
> extensions (pdf,zip,...) downloaded in PmWiki. On another site I
> maintain, I use a TCL script to postprocess HTML and insert
>> <a href="file.pdf" onClick="javascript:urchinTracker
> ('/downloads/file.pdf');"> pdf </a>
>> calls to urchinTracker. Is there any elegant way to do something
> similar in PmWiki?
Hi. For files attached to pmwiki pages, you can use in config.php:
$IMapLinkFmt['Attach:'] = "<a class='attachlink' href='\$LinkUrl'
onClick="javascript:urchinTracker('\$LinkUrl');">\$LinkText</a>";
This is for files in (:attachlist:) or in [[Attach:file.zip]] links.
If your files are in a distinct directory, different from the PmWiki uploads
directory structure, you can use the Path: shortcut:
$IMapLinkFmt['Path:'] = "<a class='sitelink' href='\$LinkUrl'
onClick="javascript:urchinTracker('\$LinkUrl');>\$LinkText</a>";
This is for files on the server, like [[Path:/downloads/file.zip | click
here]].
You can even have a special intermap Downloads: that will point to
the /downloads/ directory of your server. You set in the wiki page
Site.Intermap the line:
Downloads: /downloads/
and in your wiki page: [[Downloads:file.zip]] for a file /downloads/file.zip.
To enable the counter, you set once again in config.php:
$IMapLinkFmt['Downloads:'] = "<a class='downloadlink' href='\$LinkUrl'
onClick="javascript:urchinTracker('\$LinkUrl');>\$LinkText</a>";
Thanks,
Petko