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.
The "File name" search, only search on the current folder. It does not search files inside sub directories. What I am missing?
Comment | File | Size | Author |
---|---|---|---|
#16 | 2387943-subfolder-search-15.patch | 2.01 KB | das-peter |
Comments
Comment #1
jaffaralia CreditAttribution: jaffaralia commentedI also have the same problem. Can anyone point me in the right direction.
Comment #2
jaffaralia CreditAttribution: jaffaralia commentedPlease find the patch
Comment #3
das-peter CreditAttribution: das-peter commentedNothing, this is by design.
I'm not sure how to proceed here. Searching over all files / folders would have to be covered in global way.
Just checking if there's a filename set wouldn't do it. E.h. the user still sees the navigation even thought the navigation isn't relevant at all - this is unpredictable behaviour.
@jaffaralia Thanks for the patch! I've checked it but as explained above we would need another approach to provide an unified approach for all "searches". Further it looks the code is more complex than necessary is there a reason you didn't use
taxonomy_get_tree
e.g. like this:Comment #4
jaffaralia CreditAttribution: jaffaralia commentedNow I corrected the code. Please check.
Comment #5
jaffaralia CreditAttribution: jaffaralia commentedComment #8
das-peter CreditAttribution: das-peter commented@jaffaralia Thanks for re-organizing the code. Looks much simpler now :)
However, this won't change anything regarding my feedback that we need to come up with a proper way to achieve this without introducing "unpredictable behaviour".
So this still needs work - besides the test failures we've to look into.
Comment #9
bennybobw CreditAttribution: bennybobw commentedI also think this is confusing. @das-peter, what do you mean when you say it is "unpredictable behaviour." Our users expect that if they search inside a folder, it will also search inside sub folders. This matches users' expected behavior based on desktop searches on Mac and Windows -- if you search inside a folder it also shows you results within subfolders.
Comment #10
bennybobw CreditAttribution: bennybobw commentedAh I think I see the issue here. When you are browsing without a search, the view should not show files within subfolders. However, when you are doing a search it makes sense to show the files within the subfolders.
Comment #11
bennybobw CreditAttribution: bennybobw commentedI have a proposal for this. Add a checkbox to the filters section that says "Include subfolders in view." Toggling the checkbox will reload the view and show subfolders or not.
Then, in the "Media Files" column, it will show a breadcrumb like "Media Files > Folder 1" or if the subfolders are enabled "Media Files > Folder 1 (+ subfolders)"
Comment #12
bennybobw CreditAttribution: bennybobw commentedAttaching a patch with the include subfolders checkbox.
Comment #13
bennybobw CreditAttribution: bennybobw commentedOops sorry, I forgot to change the issue status. I based my patch on the 3.x-dev version, so I'm changing the version as well.
Comment #14
Knud Frank CreditAttribution: Knud Frank commentedI have fixed the patch to now work correctly with subfolders.
As the where clause was always adding
AND( (field_data_field_folder.field_folder_tid IS NULL ) OR (field_data_field_folder.field_folder_tid = '1') )
the search was always based on the base folder (tid = '1').
I have now corrected this, so that all subfolders (8, 9) will be included in the search and the AND clause is no longer executed.
WHERE (( (file_managed.status IN ('1')) AND (file_managed.filename LIKE '%searchterm%' ESCAPE '\\') AND (field_data_field_folder.field_folder_tid IN ('1', '8', '9')) ))
Comment #16
das-peter CreditAttribution: das-peter commentedThanks all for working on this. I like the approach.
I ended up adjusting the patch(es) a bit. I still want to ensure that we find "orphaned" files in any case if accessing the root folder. So the IS NULL condition has to stay.
But if we just adjust the condition to always work with IN, we can easily combine both approaches.
Attached patch shows what I've committed.