Drupal: theme override for Upload.module's attachments list

I made a custom override for Drupal 6.x’s Upload.module’s attachments table that is displayed at the bottom of a node when you create file attachments. That table is, in my opinion, one of the ugliest common and default presentations in Drupal core. Below is an example of the before and after:

Example of override

To use it, unzip and drop the included folder into your active theme’s directory (e.g. /sites/default/all/garland), it should take effect without any other modifications—though you may have to reset the theme cache (goto admin/build/themes and click save without making any other changes).

Click Here to Download (shiny_upload.zip)

Also, I don’t know what the name is for these types of theme overrides: it’s not a module, and it’s not a whole theme. I posted this to a Drupal Group that, I think, calls them “Themer Packs“.

The icon code is based on the CCK filefield module—but the current 6.0 version is kind’ve clunky and I wanted to port it to the core Upload module. The namespace is “shiny_upload”.

Also, as an aside, the reason island94.org doesn’t currently have this enabled is because it’s still running on Drupal 5.x branch

AttachmentSize
shiny_upload.zip11.79 KB

wow, what a difference! thx a lot for this hack.

Although it’s a little bit bigger then the usual snippet; you could add it to the Drupal handbook on the Theme Snippets page (http://drupal.org/node/45471) ?

Thanks! These kind of small changes can make a use difference to the looks of a site.

This is a great bit of code. In trying to control the look of the filename, I noted that there’s a missing closing span tag on line 23 of upload_attachments.tpl.php, to close the class=file-name block. It should read:


$file_metadata = ‘

*oops* my use of code tags didn’t work, so ignore the ‘it should read’ bit.

How could us alter this code to open the associated link in a new browser window?

This is a great bit of code. But really didn`t make any difference. Thanks anyway

Whoa, this is slick.

Any way this can be made to work with 5.x? Any pointers for me to backport it?

Thanks for this!

Hi,

Thanks very much for this! It works fine in 5.x with the Zen theme. To get it to work, I madea few minor amendments.

1. Add the following to your template.php

function phptemplate_upload_attachments($files) {
return _phptemplate_callback(’upload_attachments’, array(’files’ => $files));
}

2. Place upload_attachments.tpl.php, shiny_upload.css, and the file-icons folder in the same directory level as template.php

3. In the function _shiny_upload_create_icon_path, I used path_to_subtheme

$iconpath = path_to_subtheme()
.’/file-icons/’. $theme .’/16×16/mimetypes/’. $iconname .’.png’;

Hope this helps!

Very Very Useful. Thanks a lot.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <div> <span> <h3> <h4> <blockquote>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
To prevent spam, please type the two words you see below separated by a space. Can’t read the words?