Hi,

I have a view that shows upcoming events, however due to event repeats the title shows up multiple times if the event spans multiple days. Node:Distinct does not remove it and I do not see a filter more more control.

My question is at theme level is there a snippet of code I can use anywhere to not show a field if the title matches an existing result returned?

Thanks,
Gary

Comments

roger6106’s picture

I need something very similar. I am using the audio module, and I am trying to make a list of all the artists that have audio files on the site. I have tried distinct, but it seems to only go by the node. I just care about if the field I'm retrieving is unique (the artist field).

Is there a way to do this?

ryan_courtnage’s picture

I have almost the exact same scenario. Artist nodes & Recording nodes. Recording nodes reference Artist nodes. I'm trying to display a view listing the Artist nodes that have the most recent Recording nodes referencing them.

There is no shortage of issues/requests detailing problems removing these duplicates at the Views level (ie: using Distinct:yes). I've been unable to find anything that works. So, I'm considering handling the duplicate filtering at a higher level, like the theme level. Removing duplicates from the array of nodes to be displayed should be easy enough, but how would you guarantee the correct number of results will display on the page? If Artist #1 submitted 100 individual Recordings at a time, the view would likely only show 1 result after the filtering (unless of course you always had the view load a massive number of results on which to filter - potentially a performance nightmare).

It's been a while since you posted this - did you ever find a suitable solution? Anyone else out there have an idea?

Thanks

dawehner’s picture

If you get duplicate results you have

1) selected the wrong fields: taxonomy: term instead of taxonomty: all terms
OR 2) have node access and drupal < 6.16 OR views < 2.8
3) Forgot to filter some stuff out
4) The wrong base table

I wouldn't filter them out of theme level, because paging could be horrible.

ryan_courtnage’s picture

Thanks for your reply.

1) selected the wrong fields: taxonomy: term instead of taxonomty: all terms
OR 2) have node access and drupal < 6.16 OR views < 2.8

Using "node" row style. No nodeaccess. Drupal and Views are up to date.

3) Forgot to filter some stuff out

Perhaps, but the solution escapes me. In my scenario "Recording" nodes reference "Artist" nodes, and not the other way around (I'm assuming that matters). Using Views' Relationships, I'm able to build a view that lists Artists sorted by the publish dates of the Recordings that reference them, but am unable to deal with the duplicates (ie: make Artists "distinct").

4) The wrong base table

The view type is "Node", I assume "node" is my base table?

merlinofchaos’s picture

Status: Active » Closed (works as designed)

The reason that you can't get rid of the duplicates is that you have an error in how you think about your data.

You have artists and recordings. You want to sort artists by latest recording date.

The problem is, you don't have a latest recording date. You just have a bunch of recording dates. Take my meaning? When you sort this way, you're going to get 1 entry for the artist for every recording date it comes across. Even if you use DISTINCT or something, you have the problem of basically sorting on a random recording date (since DISTINCT won't constrain which of the various recording dates possible for that artist it picks to sort on.) You need some kind of way of determining which single recording is the latest, and then sorting on that.

Now, in normal SQL, you accomplish this with a GROUP BY clause. Views 2 does not support GROUP BY. In Views 3, you actually can do this. It's also possible that the views_group_by module can help you do this, but I don't know.

ryan_courtnage’s picture

Thanks MoC, I do catch your meaning. I'll check out views_group_by. Read performance is important to me, so I might instead look to writing the latest recording date to an Artist node field when recording nodes are added. Glad you posted, very helpful. ty