HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Forcing an uploaded file to be downloaded and not played.

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#70043 (In Topic #14839)
Avatar

Community saint

I have created a music catalogue containing mp3's. I have modified GALLERY_VIDEO_GENERAL.tpl to just display a download link and not present the media player.

Everything looks fine, but when I click on the link its played by the browsers default media player.

So I added "AddType application/octet-stream .mp3" to /uploads/catalogues/.htaccess but made no difference.

Any ideas?

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#70044
Avatar

Community saint

OK. I've changed my approach and instead of changing GALLERY_VIDEO_GENERAL.tpl, I've changed sources_custom/hooks/modules/catalogue_fields/upload.php and added:

Code

in function "render_field_value"
...
case 'audio/x-mpeg':
   return hyperlink($download_url,$original_filename,true,true);

So my question now is, can I override a single function from a class in a similar way to overriding other ocPortal php functions (I've done so with ocf_make_member)? If so, how?

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#70054
Avatar

Right, there's a config option 'immediate_downloads' ('Downloads open in associated program') that you may have turned on. If that is on, ocPortal picks a mime type from sources/mime_types.php (which you can override). If it's not it should already be application/octet-stream.
Apache's mime-types is not involved here as it is piped through PHP, for security.

Regarding your specific question about code overriding, it can be done, in a very hackerish way.
This is a sources_custom/hooks/modules/search/ocf_members.php I have:

Code

function init__hooks__modules__search__ocf_members($in)
{
   return str_replace("ocf_show_member_box(\$row['id']);","ocf_show_member_box(\$row['id'],true);",$in);
}

You can see the 'init' function is named based on the file path, and then it runs a string replace over the code to make a change to it.

Certainly not elegant, but practically works well.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#70057
Avatar

Community saint

"Downloads open in associated program"  is not checked.

Currently I get a nice download prompt in Firefox, but the media player in IE.

As for your class hook, while it may not be elegant, its positively tame compared to some of the kludges I've had to implement in some applications. I once wrote an entire system simulator in javascript that worked by overriding copies of production html screens.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: