Display list of attachments in teaser view for each node.
Last modified: August 26, 2009 - 22:58
If you put this in your node.tpl.php, it will display a list of attachments in all teasers
<?php if ($page == 0) { // dont list them in full node view
if ($node->links['upload_attachments']['title']){ // anyone know a cleaner way of checking wether there are files uploaded AND listable?
print ("<B>".$node->links['upload_attachments']['title'].":</B>"); // Printing how many there are (this is what gets printed out in your "links" <div>)
print("<UL>");
foreach($node->files as $file){
if ($file->list == 1){ // check wether the files are listable in each case so that we don't print "unlistable" files
print ("<LI><A HREF=\"".$file->filepath."\">".$file->description."</A>"); //Printing the description of each file linking to it
}
}
print ("</UL>");
}
}
?>
Here is a cleaner
Here is a cleaner implementation (Drupal 5+6), that also respects the users permissions to view attachments.
Inspired by and using the same theme functions as the Core Upload module: http://api.drupal.org/api/function/upload_nodeapi/6
<?phpif ($page == 0) {
if (isset($node->files) && user_access('view uploaded files')) {
if (count($node->files)) {
print theme('upload_attachments', $node->files);
}
}
}
?>
Module: Show Uploads in Teasers
This module enables attachments in teasers for Drupal 6. Display can be controlled for each nodetype.
http://drupal.org/project/uploads_in_teasers
Unfortunately, both methods
Unfortunately, both methods don't work with private folder (made with Private upload module).
They both show full path while in private folder Drupal serves only when the path with "system", like .../system/files/folder/file.ext.
Does somebody knows how to help this?