Posted by light-blue on September 1, 2009 at 6:17pm
Jump to:
| Project: | File (Field) Paths |
| Version: | 5.x-1.3 |
| Component: | Documentation |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
How do I change the displayed filename, when I am looking at the node? If somebody uploads doc1.pdf, filefield paths renames it to agreement.doc, and I want it displayed as agreement.doc, how do I accomplish this? Currently, it shows as doc1.pdf. Should I adjust my node-nodetype.tpl.php? Or is there something easier?
Comments
#1
After a little research, this was easy. I copied and pasted theme_filefield into my own module as follows. Is there a better way?
<?php
function phptemplate_filefield($file) {
//dpm($file);
if (user_access('view filefield uploads') && is_file($file['filepath']) && $file['list']) {
$path = ($file['fid'] == 'upload')
? file_create_filename($file['filename'], file_create_path($field['widget']['file_path']))
: $file['filepath'];
$icon = theme('filefield_icon', $file);
$url = file_create_url($path);
$parts=explode('/',$file['filepath']);
$part=array_pop($parts);
$desc = t('!name (original filename: !orig)',array('!name'=>$part,'!orig'=>$file['description']));
return '<div class="filefield-item">'. $icon . l($desc, $url) .'</div>';
}
return '';
}
?>
#2
Agreed, this is definitely a must, I came across the same issue myself not long ago.
Will look into a better solution.
Cheers,
Deciphered.
#3
I ended up theming node-nodetype.tpl.php and it worked out very well.
But really... this functionality should be built in...