First thing you need to do is create a field to store the thread id
in phpmyadmin or the acp if you have access to run sql queries run the following
PHP:
ALTER TABLE `dbtech_downloads_filegroup` ADD `threadid` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `mirrors`;
If you have a table prefix you need to modify it for that. So if you have a prefix of vb_ it would be
PHP:
ALTER TABLE `vb_dbtech_downloads_filegroup` ADD `threadid` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `mirrors`;
Then you need to update the code when it creates the thread to update the download record
Open
dbtech/downloads/modules/uploadModule.php
At about line 342 you will find
PHP:
$this->post_new_thread();
}
}
}
Replace it with
PHP:
$threadid = $this->post_new_thread();
}
}
}
if (is_numeric($threadid))
{
$this->registry->db->query_write("
UPDATE " . TABLE_PREFIX ."dbtech_downloads_filegroup
SET
threadid = " . intval($threadid) . "
WHERE groupid = " . intval($this->groupid)
);
}
Next we need to create the link for downloads that have a thread id
Open
dbtech/downloads/actions/download.php
Find
PHP:
$vbulletin->options['allowbbimagecode'] = $bbimgcodeval;
replace with
PHP:
$vbulletin->options['allowbbimagecode'] = $bbimgcodeval;
if ($fileinfo['threadid'] > 0)
{
$thread_title = $db->query_first("
SELECT
title
FROM " . TABLE_PREFIX . "thread
WHERE
threadid = " . intval($fileinfo['threadid'])
);
$fileinfo['threadlink'] = '<a href="' . fetch_seo_url('thread', $fileinfo) . '">' .$thread_title['title'] . '</a>';
}
Lastly, we need to add the code to the template to display it
ACP->Styles & Templates->Style Manager
Edit templates for your styles that you want to display the link
Open template dbtech_downloads_download
Find
PHP:
<li class="downloads-fileinfo-item""><span class="downloads-fileinfo-item-subject">{vb:rawphrase dbtech_downloads_downloads}</span> <span style="float: right;">{vb:var file.downloads}</span></li>
Replace with
PHP:
<li class="downloads-fileinfo-item""><span class="downloads-fileinfo-item-subject">{vb:rawphrase dbtech_downloads_downloads}</span> <span style="float: right;">{vb:var file.downloads}</span></li>
<vb:if condition="$file[threadlink]">
<li class="downloads-fileinfo-item""><span class="downloads-fileinfo-item-subject">Discussion Thread</span> <span style="float: right;">{vb:raw file.threadlink}</span></li>
</vb:if>
That should display the link under the downloads total
Let me know if you have any problems with that