I wanted to try to use the file's description instead of the file name for the actual link text. So I created a custom phptemplate_filefield() in my template.php file and proceeded to replace check_plain($name) with check_plain($desc). It appears as though the line
$desc = $file['description'];
does not actually reference the description. I noticed the descriptions are kept in the node_content_XXX tables themselves, so I wrote a couple of lines inside my custom phptemplate_filefield() function to query for the correct descriptions. This isn't very efficient, as a custom if statement must be used for each separate file instance. Any help or suggestions would be appreciated.
Comment | File | Size | Author |
---|---|---|---|
#14 | filefield_description_link.patch | 2.6 KB | quicksketch |
#2 | filefield-description-link.patch | 1.23 KB | jpetso |
Comments
Comment #1
jpetso CreditAttribution: jpetso commentedI solved this in a proper way with my revisions support patch, along with using {file_revisions} for the 'description' value. The key to the solution is to pass the given $item, not a newly loaded $file, in filefield_field_formatter(). $item already contains all the required data, description included.
Let's remember to close this bug once the revision patch has been applied.
Comment #2
jpetso CreditAttribution: jpetso commentedThis patch should do it. I can't test it currently because my database scheme is different than HEAD's, but I'm pretty confident that it works. Please test and review.
Comment #3
jpetso CreditAttribution: jpetso commentedUpdate the status, my patch is for filefield HEAD.
Comment #4
jpetso CreditAttribution: jpetso commentedOn further thought, this should be a feature request instead of a support request.
Comment #5
roginald CreditAttribution: roginald commentedI tried the patch and it seems to work when viewing the content node. However now it looks as though the file links are not showing up when including a filefield inside a view. I'll look around a bit more to see if I can find the problem. Thank you for the patch.
Comment #6
jpetso CreditAttribution: jpetso commentedThanks for the hint, I can see now why my patch didn't work. I committed an improved version to filefield HEAD, both description texts and Views listings work now.
Comment #7
roginald CreditAttribution: roginald commentedPerfect, works like a charm. Thank you.
Comment #8
(not verified) CreditAttribution: commentedComment #9
TimG1 CreditAttribution: TimG1 commentedDoes this patch work for 6.x-3.0-alpha7?
-Tim
Comment #10
quicksketchYou don't need to apply the patch because it is included in the current version (alpha7).
Comment #11
quicksketchComment #12
lupus78 CreditAttribution: lupus78 commentedI have Alpha7 installed, but i can't figure out how to use the Description instead of the filename as the link text!
Please someone shed some light on it :)
Comment #13
quicksketchHmm, you're right. For some reason the "description" is only used as the link "title" attribute, not the text of the link. I'm marking this active since I think it should be the default output. If the description is present, then it should be the text and the filename should be the "title" attribute.
<a href="{file-url}" title="{file.png}">{description}</a>
Comment #14
quicksketchOh, well I meant to set this issue back to active. Regardless, this is now fixed because I've committed the attached patch which makes the description the link text by default.
Comment #15
nightlife2008 CreditAttribution: nightlife2008 commentedHi folks,
I don't know if I'm the first to encounter this bug, but when I updated my FileField module to v6.x-3.0-beta3, I noticed that the hyperlinks to my uploaded files were all being displayed as "a".
The issue seems to be that properties of files are being serialized before saving in the database in table 'content_field_FIELDFIELD_ID'.
There should be a unserialisation before using these values, and after skimming through the code I noticed there wasn't, so the first lettre of the serialised string was being used, namely 'a' from 'a:1{}'.
The fix is easy:
Open up filefield_formatter.inc, go to line 16 where you see the following function:
Change this to:
Sometimes the filedata array is already unserialised, but when called from a view, it seemed not unserialised, and thus I had to fix the code.
That should do it :)
Greets!
Comment #16
quicksketchnightlife2008 this has already been fixed, see #299329: No display of alt or title with images - Simple Workaround.