When a node is displayed that has attachments; the table of attachments is displayed at the bottom of the node content.

How would I re-position the attachment table to the top of the content?

John
www.drupal.com.au

Comments

bobdavis’s picture

1. Hand code your own table and turn off the listing for each attachment item. That is the easiest.
2. Mess around with the code of the module and perhaps it would even require core code changes, I don't know as I've never looked at the upload module code.

DriesK’s picture

open upload.module, and near line 388 (in upload_nodeapi), change

$node->body .= theme('upload_attachments', $node->files);

to

$node->body = theme('upload_attachments', $node->files) . $node->body;
jdsaward’s picture

What I did after reading the pointers received from bobdavis and DriesK:

Found the appropriate code in upload module and just put it into my node.tpl.php file.

Thus:

	if (count($node->files) && !$teaser) {
          print theme('upload_attachments', $node->files);
        }

This works. Delivers the result I want.

I left the attachment table also at the bottom of the node; as for my purpose that is actually good. I just need it up top of some quite long nodes, so it doesn't get lost.

Now, as I said, it works. But I am doubtful if it is theoretically correct to use the theme function in this way within a node.tpl.php file. Any comments from those more experienced than me?

I certainly like this way better than hacking the upload module.

John

Dubber Dan’s picture

I see how that puts the list at the top before the body. How about placing it in the middle of the body?