Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using a views to search a new file to insert. Usefull to easy configurate filter (exposed or not) from UI
Screenshot into attachment.
Comment | File | Size | Author |
---|---|---|---|
#40 | Screen Shot 2014-06-12 at 1.16.17 PM.png | 72.89 KB | capellic |
#30 | filefield_sources_view.png | 8.99 KB | darrylh |
#27 | filefield_sources-views_source-1170928-27.patch | 16.75 KB | presleyd |
#23 | filefield_sources-views_source-1170928-23.patch | 17.61 KB | cecrs |
#17 | filefield_sources-views.png | 11.37 KB | presleyd |
Comments
Comment #1
mavimo CreditAttribution: mavimo commentedPatch
Comment #2
mavimo CreditAttribution: mavimo commentedPatch to use with drush make:
Comment #3
bohz CreditAttribution: bohz commentedHI, mavimo.
how difficult would it be to backport your patch to d6?
Ciao!
Comment #4
mavimo CreditAttribution: mavimo commented@bohz: I don't use D6 version of fielfield_sources, but i think is not complex do it. I can try to backport into next days or, if you can start to backport it, ping me if you have some question ;)
Ciao!
Comment #5
scroogie CreditAttribution: scroogie commentedLooks nice. Subscribing.
Comment #6
quicksketchThis patch is similar to #904758: Views-based File Browser. Both have patches so I don't want to mark either duplicate. I'm not spending a lot of time on FileField Sources, so more testing/reviewing on these issues would be appreciated.
Comment #7
quicksketchThis is a good patch. I cleaned it up to work with the latest code and tidied up the JavaScript implementation a bit.
My plan is to include this only in the D7 version, which probably means we'll branch FileField Sources into 2.x branch with this feature and the option for paste from clipboard (#1768740: New Source: Paste from Clipboard).
Comment #8
dep85 CreditAttribution: dep85 commentedWith FileField Sources: v1.6 and Views: v3.5 I get message
Notice: Undefined property: view::$dom_id w template_preprocess_views_view() (linia 115 z ...\sites\all\modules\views\theme\theme.inc).
I fix that for now by adding
$view->dom_id = 0;
to theme_filefield_source_views_element function.
I'm know that $dom_id should be unique. But it works.
And I see that you still call file js/view.js what doesn't exist any more (views.inc - line:98)
Comment #9
karljohann CreditAttribution: karljohann commented@quicksketch if I backport this to the D6 version, would you include it?
Comment #10
karljohann CreditAttribution: karljohann commented#1889158: fielefield_source: views as source
Patch for 6
Comment #11
presleyd CreditAttribution: presleyd commentedRerolled the patch for version 1.7. Seems to be working for me with images. I'm going to mess around with the view some to see what all I can do with this.
Comment #12
presleyd CreditAttribution: presleyd commentedThe issue with #8 is present I noticed. Steps to reproduce:
Comment #13
presleyd CreditAttribution: presleyd commentedEasy fix. The view should be rendered with the preview function instead of render. One word fix seems to have solved it. This feels better than the terribly hacky way I was thinking of incrementing dom_ids until I found an available one...
Comment #14
N20 CreditAttribution: N20 commentedI patched filefield_source with #13 but cant see any option to use a view for my file field. Are there any documentation or similar issue (cant find anything at the moment).
Thanks, N20
Comment #15
presleyd CreditAttribution: presleyd commentedOn that field's settings page, what options are on the file field sources? Also, did you clear the cache?
Comment #16
N20 CreditAttribution: N20 commentedThis is how settings for the filed look:
Cache was cleard.
Comment #17
presleyd CreditAttribution: presleyd commentedI can't reproduce this. I installed a clean version of the module on a fresh Drupal installation and then patched it after installation and everythig worked like a champ. It looks like this after patching.
This is against 1.7 now, I should have updated the version before...
Comment #18
N20 CreditAttribution: N20 commentedok, this happens on a BOA platform with already a ton of modules in use. I will try to disable on after one and see what happens. Will report back - thanks so far!
Comment #19
N20 CreditAttribution: N20 commentedstill the same on a fresh install. thats very strange..
Comment #20
N20 CreditAttribution: N20 commentedOk, i found the problem. After downloading the module with drush, then patching it with
patch < filefield_sources-views_source-1170928-13.patch
the fileviews.inc
was'nt created in thesource
folder - but under the root module directory. I just moved it manually into the correct place and t-a-d-a!!Thanks.
Comment #21
N20 CreditAttribution: N20 commentedThere is also a Javascript file attached in
views.inc
wich not exist:modules/contrib/filefield_sources/js/views.js
. This is called inviews.inc
around line 99.That file is not even in the 7.x-1.7 tree.
Comment #22
cecrs CreditAttribution: cecrs commentedI applied the patch, and the view is awesome, thanks! However, as N20 noted, there is a missing js file. The reference is created in the patch (line 198), but the patch doesn't include the new file. (/js/views.js)
Comment #23
cecrs CreditAttribution: cecrs commentedI found the missing js file in the patch from comment #1, and included it in a re-roll of the patch.
Comment #24
presleyd CreditAttribution: presleyd commentedIs it needed? I was just going to remove the reference to it.
Comment #25
N20 CreditAttribution: N20 commentedSo far i couldn't see that the missing file had any impact on the functionality. Seems like the views.js file attach the Image to the field on mouseklick on the button. But this works also without the file.
Comment #26
quicksketchHi guys, thanks for keeping up on this issue. My contrib modules are languishing a little bit while I'm spending a lot of time working on D8. There's a good chance we'll be seeing FileField Source-like integration in D8 directly as part of the WYSIWYG integration (#1932652: Add image uploading to WYSIWYGs through editor.module).
Comment #27
presleyd CreditAttribution: presleyd commented@N20, I don't see it's point either, quicksketch must have taken it out for a reason in #7?
Here's the patch with the reference removed.
@quicksketch, that is very good news. I'll keep an eye on that discussion. I hope to get more involved with D8 testing when my current project clears up.
Comment #28
N20 CreditAttribution: N20 commentedThanks for the patch presleyd. Now everything looks and works like it should.
cheers, N20
Comment #29
karljohann CreditAttribution: karljohann commentedI think the function was moved from views.js to filefield_sources.js. So removing the reference should suffice.
Comment #30
darrylh CreditAttribution: darrylh commentedPatch in #27 mostly works for me. The only problem I have is if you run into a validation rule - eg the chosen image dimensions are too small - the view gets a little mangled.
Comment #31
Manovra76 CreditAttribution: Manovra76 commentedThe patch have some problem after ajax call. The event.click sometime is lost:
file: field_source.js row 29
I have add this code next row 29
in this case if search something in form of use pagination, the add button is ok.
Comment #32
havran CreditAttribution: havran commented#27 with #31 works perfect, thanks. Display view in modal windows (ctools) would be great too for this functionality.
Comment #33
MxRhd CreditAttribution: MxRhd commentedI can't get the selection to work, I guess it's some typ eof JS error. I'm using 1.8 though, gonna try with 1.7 instead.
Comment #34
MxRhd CreditAttribution: MxRhd commentedWith 1.7 version it works in Seven theme, but not my custom theme built on Mothership.
With 1.8 version it does not work with either of the themes, even with the #31patch.
Comment #35
MxRhd CreditAttribution: MxRhd commentedAlso, the View-based selector does not have the option that File Attach has: Leave a copy of the file in the attach directory
I really really want this functionality, to choose from a view, and then to copy the file to a new directory.
Thanks for your hard work!
Comment #36
quicksketchAll files reused by FileField Sources *reuse* the file if it's already got an entry in the database. That includes the autocomplete, IMCE, and now the Views source. The file attach approach only copies the file because the file isn't yet managed by Drupal.
Comment #37
MxRhd CreditAttribution: MxRhd commentedAh ok. Makes sense.
I need it to copy the file though because of some advanced iamgecache text actions that uses the image entities to get node info from the image and print it on the image.
Do you have any ideas quicksketch on how I could theme the Attach to show the images with radiobuttons or what ever instead of a drop down list?
Comment #38
maxiorelMaybe a stupid question - but how should I have to configure the view to have working the Add image button?
Comment #39
capellicAs someone who has really wanted to see the Media module be successful at local media management through a View (without feeling like I am implementing a best of a module that I don't understand), this is fantastic! The road to success wasn't so smooth for me, so let me share the steps I followed using FileField Sources 1.9
It should work now. If it doesn't, clear your browser and site cache.
Thanks to all who have worked on this, is it possible to role this into Dev?
Comment #40
capellicI thought I'd document some of the features and great interface that this gives us.
If you
Comment #41
presleyd CreditAttribution: presleyd commentedI didn't need to move the files when applying the patch with the -p1 switch. They ended up in the correct place already.
Incidentally I found this the other day that is basically the same functionality in a module. https://www.drupal.org/project/visual_select_file The only major difference is that it uses a modal. I actually do not like the modal as it is a pain in mobile and I need to turn my theme off in it but its nice to have a module that does this and is being maintained.
Comment #42
presleyd CreditAttribution: presleyd commentedHrmmm the javascript has issues in 1.9 ugh javascript
Comment #43
presleyd CreditAttribution: presleyd commentedI'll share what I know so far and maybe someone else can offer some info.
the code in #31 does seem to solve the paging issue. Since that wasn't clear to me when I first saw the post I'll clarify what is happening here. The js function we are adding to the page elements gets removed when the view calls up a different page via ajax. Adding the code in 31 makes it so that the function is reattached to the new elements upon ajaxcomplete. I'm not sure if there is a more elegant way to do this. Feels odd this way but I'll update the patch to include it.
Exposed filters do not work.. at first. Clicking the apply button provided by the view seems to try to validate the page (and setting the view to autosubmit causes nothing visible to happen). Once you press a pager link or select an image and attach it.. then the exposed filters work fine. This behavior is the same regardless of the change in #31 and I'm pretty sure this used to work so there may be some views issue at work here.
Steps to reproduce:
Download filefield_sources 7.x-1.9
add patch in #27
(optional) include code suggested in #31
Enable filefield_sources
Add Views as a source to a file field
Create a new node that contains that file field
Choose 'Select Existing' by the file field
Attempt to use exposed filter to search for a file by name (or add your own filter to the view if you like)
Comment #44
Chris Burge CreditAttribution: Chris Burge commentedAlternative option for using views as a source: http://www.drupal.org/project/filefield_sources_view
I've tested the module, and with the exception of a minor notice error, it tests successfully.