[support] Drupal fields

Chris Miller cjm at tryx.org
Wed Mar 12 15:05:39 UTC 2014


Hi Folks, 

Most of the following explanation is for my benefit with the expectation that I will get corrections where I misunderstand, but the real question is just the last line of this message. 

I have an audio field which plays mp3s just fine. I need to occasionally download them. When I configure a content type, I can select a display field type of "Audio Player" or "Audio Player with Download". I need "Audio Player with Download", but this is a cruel joke! "Left-Click" just gets me "Play"; "Download" requires "Right-Click". 
When I "Inspect Element", I see a reasonably complicated block of HTML for each "Audio Player with Download". 



<section class="field field-name-field-tl field-type-file field-label-inline clearfix view-mode-full"> 
<h2 class="field-label">TL:&nbsp;</h2> 
<div class="field-items"> 
<div class="field-item even"> 
<object class="audioplayer2" height="24" width="290" data="/sites/all/libraries/audioplayers/audio-player/player.swf" type="application/x-shockwave-flash"> 
<param value="/sites/all/libraries/audioplayers/audio-player/player.swf" name="movie"> 
<param value="playerID=2&amp;bg=0xCDDFF3&amp;leftbg=0x357DCE&amp;lefticon=0xF2F2F2&amp;rightbg=0xF06A51&amp;rightbghover=0xAF2910&amp;righticon=0xF2F2F2&amp;righticonhover=0xFFFFFF&amp;text=0x357DCE&amp;slider=0x357DCE&amp;track=0xFFFFFF&amp;border=0xFFFFFF&amp;loader=0xAF2910&amp;soundFile=http://new.capitolaires.org/sites/default/files/music/tl/Sweet%20And%20Lovely.mp3" name="FlashVars"> 
<param value="high" name="quality"> 
<param value="false" name="menu"> 
<param value="transparent" name="wmode"> 
</object> 
<div class="audio-download"><b>Download:</b> 
<span class="file"> 
<img class="file-icon" alt="" title="audio/mpeg" src="/modules/file/icons/audio-x-generic.png"> 
<a href="http://new.capitolaires.org/sites/default/files/music/tl/Sweet%20And%20Lovely.mp3" type="audio/mpeg; length=1707678">Sweet And Lovely.mp3</a> 
</span> 
</div> 
</div> 
</div> 
</section> 



The way I see it, I can either hack this field to make it do what I want or I can create a display field that does what I want. 

"Hacking" would involve: 


    1. I can re-jigger the whole node in JavaScript. 
    2. Find the code which renders "Audio Field with Download" in core, and write a module that will intercept that output and modify it to the structure I want before it becomes part of the page 

"Creating" would involve: 


    1. Find the code which renders "Audio Field with Download" in core, and copy it as a Custom Formatter for "Audio Field with Download, Really" 




I don't think either of my "hacking" options are very future-proof, which leaves me with my preference, "creating", but I need to know where the code which renders the display field "Audio Field with Download" lives. Can anybody tell me w here can I find the code that outputs the HTML I see when I define a display field as "Audio File with Download"? 

Thanks for the help, 

Chris. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20140312/95fac766/attachment-0001.html 


More information about the support mailing list