Hi there,

I have "rethemed" a flexinode (node-flexinode-1.tpl.php) and would like to display the attachments (that have been uploaded using the attachment module), how do I do so?

Cheers

James

Comments

dlr’s picture

berty_boy’s picture

Cheers,

but I found the answer from

http://harkeydesign.com/node/228

I was able to manipulate the attachments as such:

lobal $user;			
				foreach ((array)$node->attachments as $attachment) {
					$attachment_info = module_invoke('filemanager', 'get_file_info', $attachment['fid']);
				    $attachment['icon'] =  str_replace('/', '-', $attachment_info->mimetype);
				    if (!$attachment['hidden'] && !$attachment['deleted']) {
						$text = $attachment['filename'];
				        $attrib = empty($attachment['description']) ? array() : array('title' => $attachment['description']);
					}
					
					if (!$user->uid){
						$attachment_file = $attachment['filename'];
					}
					else
					{
						$attachment_file = module_invoke('filemanager', 'l', $text, $attachment['fid'], TRUE, $attrib, TRUE);
					}
					echo "<div class=\"" . $attachment['icon'] . "\">\n";
					echo $attachment_file . " (" . format_size($attachment['size']) . ")";
					echo "<p>" . $attachment['description'] . "</p>";
					echo "</div>";

				}

And then creating an attachments.css to display an icon whioch is followed by the file to click on (if logged in) and the description underneath.

Thanks anyway, and I hope the code above may come in useful for somebody

James