fileupload element - displaying different file types

chris.paschen

Chris Paschen
I need to use the fileupload item to provide downloadable files.
The file needs to be displayed with just an icon and title/caption (under the icon).

I've tried all the configuration settings of the fileupload element and can't seem to (easily) make this work, short of creating a complete custom template (which is very time-consuming when I have several templates and have to modify each to handle this element.

Here's what I've already tried...

1. Access image
Changing the 'access image' setting on the Downloads tab of the element. Even though this MIGHT provide some solution (when I know the file-type of the files and they stay the same per element), clicking the icon that is displayed just links back to the same details page on the front-end (i.e. it doesn't actually provide a download link).

2. Custom template code
Here's the only way that I've been able to make it work - to completely customize each template where this element needs to be used, and by adding other elements to provide the necessary pieces of info:

PHP:
echo '<a href="'.$fileURL.'" target="_blank"> <img border="0" alt="'.$filename.'" src="'.$filetypeiconURL.'"></a>';
echo '<p class="downloadiconcaption">'.$filename.'</p>';

[NOTE: The fileupload element is part of a repeating group, one group for each downloadable file]
Where
$filetypeiconURL is a url to the proper icon (I have a 'filetype' selector in the group to allow manually selecting the proper file type, that then provides the iconURL via a db lookup).
$fileURL is the raw URL from the fileupload element
$filename is taken from a field element (so that the 'name' can be different than the actual/real filename)

I would LOVE to know if there is a way that I can just modify the fileupload element directly, to at least be able to have the icon image automatically displayed based upon the file type.

I've seen one other thread that covers something similar here:
http://fabrikar.com/forums/index.ph...element-in-table-view-solved.5954/#post-29851
But it's quite old (and doesn't match current Fabrik file/code structures).

I need to use this functionality on at least a couple other projects soon and am willing to put in some time to hack away at this (or test other code) and share back with everyone else.

If there are docs somewhere that show how to do this, please point me there (I couldn't find them searching anywhere). I'm sure this would be a help to others (and I'm surprised if I'm the first to have this need in Fabrik).

Thanks for any help you can give!
 
I see that in the /element/custom directory of this plugin it says:

You can add custom filetypes, or override the default handling of filetypes by creating files here. For instance, to modify the way you display mp3's, you would copy the mp3.php from the folder above, and change the 'require' to include a different model. You would probably then copy models/audio.php to (say) models/myaudio.php, require that from your custom/mp3.php, and modify myaudio.php to do what you need.

When looking at the files (like '/element/pdf.phg' for example), it calls another file - /models/pdf.php.
That file (/models/pdf.php) looks like it should be displaying the default icon for this file:

PHP:
// If file specific thumb doesn't exist, try the generic per-type image in media folder
                    $thumb_file = COM_FABRIK_BASE . 'media/com_fabrik/images/pdf.png';

                    if (JFile::exists($thumb_file))
                    {
                        return $thumb_file;

But it doesn't appear to be working - no icons are ever displayed on the front-end.

(But I can't find any documentation on this type of feature/functionality, so there is a good chance that I am not using it properly - or expecting different functionality than what is designed/coded into the element.)
 
I was using the GitHub version from about 4-5 days ago. I just updated and and don't see any changes (no icons displayed for the file download - just the filename as a link).

Are there ANY updated documentation for this element. The one in the Wiki is pretty outdated, and I could very well not be configuring the element properly to allow Fabrik to display an icon for the download (instead of the filename).
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top