I wrote a component and need a field there where the user can pick a pdf from the media manager. When I set the field-type in the field list to «media», the media-manager only shows images.

How do I make it show all files instead of images only?

migrated from stackoverflow.com May 20 '14 at 20:45

This question came from our site for professional and enthusiast programmers.

I have not tested this in later Joomla versions, but at least in 2.5.x it was possible to display a list of files in a folder in the form of the drop-down.

The path is hardcoded and rather limited , BUT for some use cases it may just do the trick and provide the flexibility needed.

Ladies and gentleman, presenting the filelist:

    <field 
        name="yourfile" 
        type="filelist"
        label="COM_EXAMPLE_FIELD_YOURFILE_LABEL" 
        description="COM_EXAMPLE_FIELD_YOURFILE_DESC" 
        directory="media/com_example/files/"
        hide_none="true"
        hide_default="true"
    />

In case anyone is still interested, I've described a solution here, where a plug-in is used to override the imageslist view of com_media so that it shows all files in the media manager. I've put the code on GitHub.

I'd be first to admit that this is a less than elegant solution, but it works for the project I developed it for. I would treat this code as a starting point for your project, not a polished solution.

  • 1
    Welcome to StackExchange. It's generally better to include the solution (or part of it) in the answer. If the link breaks the answer is useless. – johanpw Apr 1 '15 at 11:44
  • I used your plugin in Joomla 3 as well. Because this issue is still not resolved. – COBIZ webdevelopment Nov 7 '15 at 17:44

Extending on the suggestion by @ValentinDespa, you can use the filelist form field type, and add a filter parameter. Any regular expression can be added here, see example below for how to filter PDF-files only.

<field type="filelist" name="pdf" label="Select PDF" directory="images" filter="\.pdf$"/>

enter image description here

This works fine in Joomla 3.x, BTW.

The Media form field type is used to select an image. So it filters out other files. Have a look at Joomla documentation for the available standard form fields types. You might also want to consider to create your own custom modal form field type for your component.

  • 1
    That's a joke, right? The media manager lets me upload PDFs, video and whatnot, but it won't let me actually SELECT them? I'm forced to write my own form-field? Isn't there a way to tell the Media-field to NOT exclude other files? (I know you're not responsible for this behavior, so don't take this rant-like reply personally :) – Swissdude May 21 '14 at 20:59
  • Unfortunately, as far as I remember, the filter is actually hardcoded. – Valentin Despa Jun 23 '14 at 15:14

You can use JCE editor with plugin file manager.

https://www.joomlacontenteditor.net/downloads/plugins/file-manager

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.