5

I’m stuck into something about File and Relationship and looking for help. I’m wondering if there is a way in EE2 to have something like Playa but for file relationship.

Basically, I have a bunch of images updated on a folder “my_images” via the File Manager. I would like to get a field on a channel that could list all the files of that specific folder so admins could pick one of already stored images. The same way for instance, Playa is doing when you want to create a relation between an entry to another entry. But in that case it would be between a file and an entry.

I know there are numerous ways to handle that using channel images for instance but the thing is we already have a bunch of images stored on the folder “my_image” uploaded via the file manager plus, we don’t really want to have an “Upload” functionality on the channel entry. Only a way to select a stored image of the folder “my_image” that would create a relationship.

If someone knows something about it, a module or a direction to look into, it would be greatly appreciated.

1
4

You could use MX Select Plus to accomplish this. Then in the settings for that custom field use the DB request and run a query like below. Make sure to define the upload_location_id. You may need to modify the query to your needs:

SELECT file_id AS option_name, 
file_name AS option_label
FROM exp_files 
WHERE upload_location_id = X 
ORDER BY file_name ASC
3

If having the upload functionality is not a killer then you could accomplish this quite easily with SafeCracker File. Of course if you are wanting to prevent any further uploads then this won't be an option without altering the fieldtype (which wouldn't be too hard).

Update:

Editing ft.safecracker_file.php and replacing line 77 will remove the upload option from the fieldtype.

I have commented out the line below and added a line to prevent PHP notices.

$vars = array(
        'data' => $data,
        'hidden' => form_hidden($this->field_name.'_hidden', $data),
        //'upload' => form_upload($form_upload),
        'upload' => '',
        'placeholder_input' => form_hidden($this->field_name, 'NULL'),
        'remove' => form_label(form_checkbox($this->field_name.'_remove', 1).' '.lang('remove_file')),
        'existing_input_name' => $this->field_name.'_existing',
        'existing_files' => $this->existing_files($this->settings['safecracker_upload_dir']),
        'settings' => $this->settings,
        'default' => FALSE,
        'thumb_src' => $thumb_src
    );
0

Why not use Assets? Has an excellent UX, and file uploading can be disabled per usergroup, and it should work with files that were already uploaded via the file manager.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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