2

We have a view for a type of node that includes a Private File.

We cannot see a way to add an exposed filter, such as "Contains any word", and have it filter based on the file's name.

Are we missing something obvious?

2 Answers 2

5
+100

Here's how to set that up:

  1. Make sure you are not displaying teaser/full nodes. This works only for fields.
  2. Under Relationships add your file field. You should select Content: [field name] (field_field_name:fid).
  3. Create new Filter Criteria and choose File: Name.
  4. Choose appropriate operator and optionally expose it to the visitors.

Hope this helps.

0

you can take a look to https://drupal.org/project/file_entity module: "This allows for additional information to be stored along with a media file such as Title, Description, Taxonomy References, Node References, Location, Date created, License information etc."

If you are not able to find a solution in this way, you can create your own filter views handler. In this case, it would be a filter handler.

https://api.drupal.org/api/views/handlers!views_handler_filter.inc/group/views_filter_handlers/7

https://drupal.org/node/1239866

Extending views functionallity to provide an approach to your problem (How to provide a custom option for an exposed filter in Views?)

Your "custom filter views handler" could get the fid of your file for each node from "field_data_field_yourfieldname.field_yourfieldname_fid" and make a join with "file_managed.fid".

In this way you can match the text introduced by the user with "file_managed.filename" database field.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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