I have setup Flexinode to do exactly what I want except for this one item: I have a Flexifield setup to allow multiple values to be entered.

For example, a Flexifield may be like:

Black | Square
White | Square
Black | Round

Now I've setup a view to display the nodes and used a Relationship so that I can field the view on the Flexifield values. However, if a node's flexifield has more than one value (like quantity three in the example above) then the node is output in the View Multiple times.

In the example above, that node would be output three times! Is there any way to show the node only once?

Comments

jsimonis’s picture

I have the exact same issue. It wasn't until today that I realized this was what was causing me to have duplicated items on my views.

3CWebDev’s picture

I need to solve this. Have you, or anyone, made any progress on finding a solution?

3CWebDev’s picture

okay, easy fix. Simply checking the 'distinct' check box in your view will fix this issue.

jsimonis’s picture

How did you get it to show all the options for the field? I've got a set of fields that give information on a place of lodging - # of rooms, # of bedrooms, type of lodging, etc. They are a group and you can add more of that group.

I just turned on distinct and I am only seeing the first set of information about the rooms, not the others.

3CWebDev’s picture

If I understand your issue correctly then I am not experiencing that on my site. I am able to show multiple flexifield files on the Views output while using the distinct option.

I simply included the Flexifield field into my view using the default settings and it works.

jsimonis’s picture

You're including the entire flexifield?

I need to have just part of my flexifield show (such as number of rooms) on some views.

3CWebDev’s picture

Yes, I'm including the entire flexifield so that must be the difference. With this method it allows me to display all the flexifield values and also to filter and search for the values of each node's flexifield values.

jsimonis’s picture

Ok, I'll see if there is a way to pull the whole thing but only show a piece.

mayur.pimple’s picture

im just enable distinct in views but it not working .
any other solution

zanix’s picture

I also have this issue, although I almost have a work around
I got the idea from this issue comment #13
#300668: Add views integration
It was a workaround to get all of the fields from a flexi-field into the main view before it was fixed

In my view, I added the flexi-field as a field
Then I added a customfield: php code field and added this to it

$return = '';
foreach ($data->node_data_field_cr_ff_attendees_field_cr_ff_attendees_item_id as &$el) {
  $el['value'] = unserialize($el['value']);

  $el_new['value']['field_cr_attendee_name'] = $el['value']['field_cr_attendee_name'];
  $el_new['value']['field_cr_attendee_type'] = $el['value']['field_cr_attendee_type'];

  $el['value'] = $el_new['value'];

  $aElement['#node'] = node_load($data->nid);
  $aElement['#item'] = $el;
  $return .= theme('flexifield_formatter_default',$aElement);
}

return $return;

For this line, you will need to dsm($data); first to the get name you need for your form
$data->node_data_field_cr_ff_attendees_field_cr_ff_attendees_item_id

This line gets all of the values inside of the flexi-field

  $el['value'] = unserialize($el['value']);

So I created a new array, and pulled only the fields I needed into it

  $el_new['value']['field_cr_attendee_name'] = $el['value']['field_cr_attendee_name'];
  $el_new['value']['field_cr_attendee_type'] = $el['value']['field_cr_attendee_type'];

Then put the newly created array back into the first array
$el['value'] = $el_new['value'];
The last 3 lines render the fields and return them to the view

This workaround will print both the label and value for the fields you specify in the php code
If you only want the values...I had to make some css to hide the label fields

<style type="text/css">
.field-field-cr-attendee-name { float: left; clear: left; }
.field-field-cr-attendee-type { float: left; margin-left: 4px; }

.views-field-phpcode { white-space: nowrap; }

.field-field-cr-attendee-name .field-label,
.field-field-cr-attendee-type .field-label { display: none; }
</style>

I have yet to find a better way to do this
I intend to look into it, but I am a novice Drupal developer and I am still learning the ropes

zanix’s picture

To hide the labels, you can edit the content type display values of the flexifield by setting Label to <hidden>
This will hide the labels in your custom view, but it will also hide them when viewing the content node

Gomu’s picture

Category: support » bug

I did not find this problem in alpha5.

I faced the reverse problem. I have a flexifield (say A) with multiple values attached to a content type (say C). I created a view of nodes of C and added the sub-fields of the flexifield. I wanted a complete list of all instances of the flexifield in all nodes. I could set it up fine with relationship. It worked beautiful.

However, one problem arose. Pagers were not appearing as they were supposed to. After some debugging I found that $query and $count_query in includes/views.inc were going out of sync after the db_rewrite_sql. DISTINCT was removing the duplicate occurrences of node C from $count_query. So, though 63 rows were returned by $query, $count_query returned 17. So there were not as many pages as there should have been.

To solve this, I have put a temporary fix in includes/views.inc after the db_rewrite_sql for $count_query.

$count_query = str_replace('SELECT DISTINCT ', 'SELECT ', $count_query);

With this fix, it is working fine. I have not seen any other side-effects on other views in the system too.

If any one has faced the same problem and has a better solution, please let me know.