By conkdg on
Hello All,
I'm trying to figure out how to display node file attachments (using standard upload.module) to unregistered users, but require registration in order to complete the download?
The following function looks like it displays the file download table in nodes, but I can't seem to figure out where it's called from (and where access permissions come into effect) for this function.
Anybody have any good ideas on how to accomplish this?
/**
* Displays file attachments in table... from modules/upload.module
*/
function theme_upload_attachments($files) {
$header = array(t('Attachment'), t('Size'));
$rows = array();
foreach ($files as $file) {
if ($file->list) {
$href = check_url(($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))));
$text = check_plain($file->description ? $file->description : $file->filename);
$rows[] = array(l($text, $href), format_size($file->filesize));
}
}
if (count($rows)) {
return theme('table', $header, $rows, array('id' => 'attachments'));
}
}
Comments
Forgot to mention that I'm
Forgot to mention that I'm running Drupal 4.7.2
shouldn't be too hard
It doesn't really matter where this is called from, you can override it in your theme's template.php file (assuming your theme is phptemplate-based). I'd try something like the below. A quick test on my scratch site seems to work, though I think anonymous users could still download if they can guess the path to the file.
let me know if this works for you...
---
Work: BioRAFT
pwolanin - This is just what
pwolanin - This is just what I was looking for. Thank you VERY MUCH!
Just FYI, this is the final
Just FYI, this is the final function I ended up using. Since logged-in users are already going to see the files, I made this visible only to non logged-in users. I put this function in a module file, and called it from my node.tpl.php file just after the $content is displayed. Cheers!