I'm using a custom template for a node and print $node->field_download_version[0]['view'] is my download. The download shows up, but it isn't tracking through download count or showing the count (X) next to it.

How can I wrap the download in the public download counter so that it'll work on custom nodes?

Comments

pixture’s picture

Assuming that $node->field_download_version[0]['view'] returns a text which contains anchors like <a href="http://yoursite/dir1/filename.zip">filename.zip or some text</a> , add the following code.

$text = $node->field_download_version[0]['view'];

if (function_exists(_filter_pubdlcnt)) {
  $text = _filter_pubdlcnt($text, $node->nid);
}

// do something like print $text

This should convert any file download anchors inlcuded in the $text to use PDC, and also add count (X) too.