Note: This is quite detailed... but I'm aiming for clarity. :-)

I have a Drupal 6 site where I currently use the "Upload" module to attach (my own original) MP3 music files to nodes with a custom content type called "Performance". A "Performance" can have multiple files attached. The filenames can be arbitrary so I use the "Description" field to enter the exact title of each song. I then use a view to list all performances of all songs with a particular title. The view takes the title as an argument. I'm able to embed this view into the master page for each song (using "Contemplate" with a separate "Song" content type) so that it contains a list of all performances. This is a very natural approach and it works very well - I don't have to double-handle anything.

I want to move the site to Drupal 7, where the "Upload" module is apparently gone and replaced by "FileField". I can move my attachments to use "FileField" instead. However, (at least in the Drupal 6 version of "FileField") I can't filter a view on the "Description" field.

I don't see how I can get the same result in Drupal 7 as I currently do in Drupal 6 with "Upload". I'm probably being thick because I'm looking for something too close to my current solution.

Can someone please suggest a way of doing with "FileField" and "Views" what I currently to with "Upload" and "Views"? Any suggestions greatly appreciated...

Thanks...

peace & happiness,
martin

Comments

quicksketch’s picture

Unfortunately filtering on the description column is practically impossible. The description is stored in a serialized data column, making sorting through any normal means impossible.

Fortunately in Drupal 7, we stopped doing such terrible things and the column is now dedicated specifically to description, so it's possible again in Drupal 7. Unfortunately I'm not sure that Drupal 7 Views module has support for this yet. if you're using Drupal 7, I suggest moving this issue to the Views module queue, otherwise I'll close it here as "won't fix", since this isn't feasible in Drupal 6.

Martin.Schwenke’s picture

Project: FileField » Views (for Drupal 7)
Version: 6.x-3.9 » 7.x-3.x-dev

Thanks for the reply... that sounds very positive!

I'll move this to the Views queue as you suggest.

Thanks again...

Martin.Schwenke’s picture

The summary now is that I'm wondering if Views 3.x in Drupal 7 has, or will have, support to filter on the FieldField Description field.

Thanks...

dawehner’s picture

Status: Active » Fixed

Yes this is possible in d7. Views allows to filter by everything, which has a column in the database.

Martin.Schwenke’s picture

Thanks for the reply and confirming that this will work!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

WorldFallz’s picture

Status: Closed (fixed) » Active

it may well be possible, but I can't seem to figure out how, lol. It could be me-- i'm still finding my way around the new ui, but I couldn't find a field or sort item that used the file description anywhere while making a 'file' view. I'd just like a confirmation on whether or not it's there before I go ahead and try to create a patch for it.

Thanks...

merlinofchaos’s picture

Status: Active » Fixed

Any field that is listed by field api in its columns section is available. It will look something like this:

Content: Multi image (field_multi_image:title)

That's the image title available for filtering on an image field.

If it's not listed in the columns, then Views can't learn about it to offer it for filtering.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

WorldFallz’s picture

yep... my bad. now that I know what to look for and i can confirm it's there as merlin described.

acbramley’s picture

I'm trying to display a file's description through views and can't figure it out either. I've got a field called field_file_attachments which allows unlimited files to be attached to a node. I've enabled the description field so when I upload a file I can add a description as well.

I've created a "File" view and added File: Extension, File: Name, and File: Size but I can't find the description. What I'm trying to do in my view is display the file's description OR the file's name if there is no description. I can do that logic in a preprocess function I just need to get the description out!

Any help would be greatly appreciated.

aphickey’s picture

I think that description is an attribute of the node file field, not the file that is uploaded. So, maybe you can do what you are looking for by creating a node view with a fields display. Choose to display the file field you uploaded your files with. Choose "Rewrite Results" in the configure field dialog. When that is open you should see a toggle for "Replacement Patterns". I believe that the description field is in there along with the file info.

Martin.Schwenke’s picture

I figure that I might as well update this and say that this is working well for me in D7.

I'm using the Description field as the filter. Instead of using Contemplate I'm using Panels. I'm using a Node Template for the Song content type and placing another pane below the pane for the node.

The views setup wasn't completely obvious to me and took some experimentation. Now that I have it working, it is obvious... ;-)

In the content pane display for the view I add an item under "Contextual Filters":

Content: File attachments:description

Then in "Argument input":

  Content: File attachments (upload:description) source:

    From context

    Required context:

      Title

Works very nicely. Thanks to those who make this sort of thing possible! :-)

AdrianB’s picture

Just wanted to thank you to aphickey i #12 for steering me in the right direction on how to get the description field.

druvision’s picture

On the latest views 3.x, the description field is indeed invisible. But I was able to get away with it by displaying the file using the generic formatter (which displays the description automatically, together with a link to download the file). Then, I've unchecked the option to "Display all values in the same row" on the Multi-valued groupbox (collapsed by default). This enabled me to have a separate row for each file, then add more fields (like file size) to the view and even filter by them.

The following exported view displays all files attached to the current node in a block:

$view = new view;
$view->name = 'attached_files';
$view->description = 'Sow the files attached to a \'Basic Page\' node';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Attached Files';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Attached Files';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Content: Files (field_files:fid) */
$handler->display->display_options['relationships']['field_files_fid']['id'] = 'field_files_fid';
$handler->display->display_options['relationships']['field_files_fid']['table'] = 'field_data_field_files';
$handler->display->display_options['relationships']['field_files_fid']['field'] = 'field_files_fid';
$handler->display->display_options['relationships']['field_files_fid']['required'] = 1;
/* Field: Content: Files */
$handler->display->display_options['fields']['field_files']['id'] = 'field_files';
$handler->display->display_options['fields']['field_files']['table'] = 'field_data_field_files';
$handler->display->display_options['fields']['field_files']['field'] = 'field_files';
$handler->display->display_options['fields']['field_files']['label'] = '';
$handler->display->display_options['fields']['field_files']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['external'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['field_files']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['field_files']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['trim'] = 0;
$handler->display->display_options['fields']['field_files']['alter']['html'] = 0;
$handler->display->display_options['fields']['field_files']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_files']['element_default_classes'] = 1;
$handler->display->display_options['fields']['field_files']['hide_empty'] = 0;
$handler->display->display_options['fields']['field_files']['empty_zero'] = 0;
$handler->display->display_options['fields']['field_files']['hide_alter_empty'] = 1;
$handler->display->display_options['fields']['field_files']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_files']['group_rows'] = 0;
$handler->display->display_options['fields']['field_files']['delta_offset'] = '0';
$handler->display->display_options['fields']['field_files']['delta_reversed'] = 0;
$handler->display->display_options['fields']['field_files']['delta_first_last'] = 0;
$handler->display->display_options['fields']['field_files']['field_api_classes'] = 0;
/* Field: File: Size */
$handler->display->display_options['fields']['filesize']['id'] = 'filesize';
$handler->display->display_options['fields']['filesize']['table'] = 'file_managed';
$handler->display->display_options['fields']['filesize']['field'] = 'filesize';
$handler->display->display_options['fields']['filesize']['relationship'] = 'field_files_fid';
$handler->display->display_options['fields']['filesize']['label'] = '';
$handler->display->display_options['fields']['filesize']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['external'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['replace_spaces'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['trim_whitespace'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['nl2br'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['filesize']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['filesize']['alter']['more_link'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['trim'] = 0;
$handler->display->display_options['fields']['filesize']['alter']['html'] = 0;
$handler->display->display_options['fields']['filesize']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['filesize']['element_default_classes'] = 1;
$handler->display->display_options['fields']['filesize']['hide_empty'] = 0;
$handler->display->display_options['fields']['filesize']['empty_zero'] = 0;
$handler->display->display_options['fields']['filesize']['hide_alter_empty'] = 1;
/* Sort criterion: File: Upload date */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'file_managed';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'field_files_fid';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
$handler->display->display_options['sorts']['timestamp']['granularity'] = 'month';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['nid']['break_phrase'] = 0;
$handler->display->display_options['arguments']['nid']['not'] = 0;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'basic_page' => 'basic_page',
);

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');
acbramley’s picture

Title: Not being able to filter on FileField Description in a view is problematic » Not being able to filter on File field Description in a view is problematic
Status: Closed (fixed) » Active

There's still no way of sorting or filtering a view by the file description field, yes you can use contextual filters but this still doesn't cover cases of exposed filters or sorting so this isn't fixed

acbramley’s picture

I actually just found a way you can sort using file descriptions (Under the More tab on the field settings use the dropdown under "CLICK SORT COLUMN") when you're using click sortable tables in views, so I'm really confused why it's not available as a normal views sort.

Kars-T’s picture

Status: Active » Closed (won't fix)

Dear fellow Drupal enthusiasts,

This issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project, everyone is helping on a voluntary basis. That this was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex, or the problem was not described comprehensibly.

But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and it is a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.

Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.

Help can also be found for it on IRC and in the user groups.

In order to close this issue, I have set this issue to "Closed (won't fix)".

If there is new information, please re-open the issue by changing the status to active.

--
This issue was edited with the help of Issue Helper

Anybody’s picture

I won't reopen this issue, but anyway I'd like to show you a workaround that helped me a lot!
It can be found here: http://drupal.stackexchange.com/questions/31246/how-to-create-a-view-dis...

The solution is to use the views field rewrite to access the field description. It works absolutely fine!

knalstaaf’s picture

Title: Not being able to filter on File field Description in a view is problematic » Not able to filter or sort on File field Description in a view
dimaboychev’s picture

If anyone haven't noticed, by default, if there is no sort criteria then views will filter by weight. So in the node you can set the weights however you like. For now this works for me. Will spend some time later to achieve sorting by file description.

For clarity here is how my node (in edit view) and view looks like.
http://imgur.com/a/6EBbe

dimaboychev’s picture

I found a simple solution using hook_views_query_alter. The solution provided by Anybody didn't work for me.

So I noticed that the description field is available in the filter criteria of the view but not in the sort criteria
Then I enabled the display of generated view query (views settings) and saw that the query has the description field for whatever reason...

So in my query alter I just added the sort like so:

function YOURMODULENAME_views_query_alter(&$view, &$query) {
if ($view->name == 'YOURVIEWNAME') {
$query->orderby[0]['direction'] = "DESC"; //ASC for ascending
$query->orderby[0]['field'] = "YOURALIAS"; // i used the field alias here that was already in the query. you can probably use
// the table_name.FIELDNAME_description. The table_name in the database is going to be prefixed
// with field_data_field_WHATERVERYOUNAMEDTHEFIELD
}