[support] Trivial module, or something else and not module at all?

Chris Miller cjm at tryx.org
Fri Mar 21 15:28:42 UTC 2014


Hi Folks, 

Not sure how to proceed... 

I want to be able to download files with a click, not a right-click context menu item. This is pretty easy. I have a custom formatter that will present the file as the argument to a script. The custom formatter looks like this: 



$s = '<a href="' . drupal_get_path('module', 'download') . '/download.php?file=' . $variables['#items'][0]['uri'] . '">'; 
$s .= '<img class="file-icon" alt="" title="audio/mpeg" src="/modules/file/icons/audio-x-generic.png">'; 
$s .= '</a>'; 
echo $s; 


And the script is equally simple: 



header('Content-Description: File Transfer'); 
header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename='.basename($file)); 
header('Content-Transfer-Encoding: binary'); 
header('Expires: 0'); 
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
header('Pragma: public'); 
header('Content-Length: ' . filesize($file)); 
ob_clean(); 
flush(); 
readfile($file); 


So, here's the question. I need this script to be a module, so the custom formatter can find it (drupal_get_path()). I have a trivial download.info and an empty download.module. This is really just a utility script and not really a module. What is the recommended way to "register" this script for general use? hook_menu? 

Chris. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20140321/f51161c7/attachment.html 


More information about the support mailing list