ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Files Relationship Field

November 20, 2012 12:29pm

Subscribe [2]
  • #1 / Nov 20, 2012 12:29pm

    Origin

    4 posts

    Hey there,

    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.

    Thanks for your help folks and have a great day !
    And happy thanksgiving to our fellow Americans.

    Sebastien

  • #2 / Nov 20, 2012 3:41pm

    blendimc

    150 posts

    If you haven’t looked into http://www.devdemon.com/channel_images/ I’d give it a try. I’ve used it before with much success. Seems to be addressing the problems you are having.

  • #3 / Nov 20, 2012 4:07pm

    Origin

    4 posts

    Hi there,

    Thanks for your reply but as I said above, Channel Images is not really adapted for this particular case because it has its own way of handling images, differently from the native File Manager of EE. The “Stored File” functionality of Channel Images can’t display the images uploaded via the File Manager. And all the images we want to use are already uploaded using the File Manager. Plus, this is not an upload functionality we’re looking for, but a relation tool between an Image and an Entry.

    I really appreciate you answered though! I’m thinking we might need to create a custom module for that but I’m wondering if there is not yet a module doing this.

    Sebastien

  • #4 / Nov 20, 2012 4:24pm

    Austin Siewert

    129 posts

    Sebastien,

    Did you see my answer on the beta EE StackExchange site. I believe it’s exactly what you’re looking for: http://expressionengine.stackexchange.com/questions/122/relate-files-like-playa-fields

  • #5 / Nov 20, 2012 4:31pm

    Austin Siewert

    129 posts

    Looks like your need to have access to the site to see the answer.

    You could use MX Select Plus to accomplis 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

     

  • #6 / Nov 20, 2012 5:03pm

    Origin

    4 posts

    Hey Austin,

    Thanks for your answer it’s a really interesting module, especially the fact we can use DB request. I really love that idea. I don’t know yet if we’re going to use that for the current issue as the client would like to see the thumbnail to help choosing the image (which makes sense when you think about it). But we might use this Select Plus Module for other things.

    Thanks for the tips.

    Sebastien

  • #7 / Nov 20, 2012 5:23pm

    Austin Siewert

    129 posts

    I guess I’m confused on why the regular file field wouldn’t work in this case–choose the directory you want and it shows both list & thumbnails. It seems if they’re capable of using the File manager to upload new images, they would be able to instruct them on how to use this. Plus, it seems kind of backwards to me.

    If you adding a image to a channel entry, why wouldn’t you do that while publishing/editing that entry? Rather then going to the file manager, upload file, then find entry to associate the image to

  • #8 / Nov 20, 2012 6:06pm

    Origin

    4 posts

    Well, I’m the one which is confused now. We barely use the File Manager on channels and mostly use the Channel Image module. I thought inside an entry, the regular file field would just allow admins to upload a new image and not pick a stored one. Which is completely wrong as you describe on your message. And it’s actually pretty handy. I feel kind of dumb now for not even tested that, but thanks a lot for pointing the obvious. It just works as is.

    Thanks again for your support Austin, and for the useful link above (MX Select Plus).
    Sebastien

  • #9 / Nov 27, 2012 11:54am

    blendimc

    150 posts

    There was another response on the Stack Exchange site, does this help at all?

    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
        );
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases