Solved

Views and to-many relationship (in service output)

Posted on 2010-08-16
3
689 Views
Last Modified: 2012-05-10
Hi experts!
I have a Drupal installation (newest of 6 branch) with cck, views and service modules installed.
I'm building a application with a drupal backend and a Flex client. So I want to exchange data. Everythings works fine except one thing:

The service output of to-many relations is weird. I have 2 content types: Artist and Video. Each video can have 1 or more related Artists.
I have 2 artists and two videos. the second video has BOTH artsts attached.

Video1 (nid: 10)
 - Artist 1
Video 2 (nid: 12)
 - Artist 1
 - Artist 2

The result looks like this:

Array
(
    [0] => stdClass Object
        (
            [nid] => 10
            [node_title] => Interview with Metallica
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Metallica
            [node_node_data_field_related_artists_nid] => 9
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 9
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => Thrash Metal
            [node_node_data_field_related_artists_title] => Metallica - Biggest Metal Band ever
        )

    [1] => stdClass Object
        (
            [nid] => 12
            [node_title] => Mixed Interview
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Slipknot
            [node_node_data_field_related_artists_nid] => 11
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 11
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => NuMetal
            [node_node_data_field_related_artists_title] => Chaos Metal Head from Iowa
        )

    [2] => stdClass Object
        (
            [nid] => 12
            [node_title] => Mixed Interview
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_name_value] => Metallica
            [node_node_data_field_related_artists_nid] => 9
            [node_node_data_field_related_artists_type] => artist
            [node_node_data_field_related_artists_vid] => 9
            [node_node_data_field_related_artists_node_data_field_artist_name_field_artist_genre_value] => Thrash Metal
            [node_node_data_field_related_artists_title] => Metallica - Biggest Metal Band ever
        )

)

Open in new window


The "nid" of the second and third entry is the same.
I want just 2 items in the array. The second one should have an array with all related artists.

Is that related to the delta settings? I didn't find detailed information on "delta". But playing around with it doesn't solve my issue. Then only one of the two artists is included. That sucks. What I'm I doing wrong?

Thanks in advance!
Simon
0
Comment
Question by:simonwidjaja
  • 2
3 Comments
 
LVL 17

Expert Comment

by:Thomas4019
ID: 33446528
It's a known problem, when you setup anview with a many to one relationship where the delta is set to "all", duplicates appear. What happens is each value in the many to one relationship creates a new row. Looking at your screenshot, I see the nid 12 is included twice. You could probably manually join the on the flex end. Or google views duplicates to see others solutions. Here's one related thread, http://drupal.org/project/dhtml_menu.
0
 

Author Comment

by:simonwidjaja
ID: 33447179
so there is NO solution?

I don't get the link you posted. Where is the connection between Views and DHTML?
0
 
LVL 17

Accepted Solution

by:
Thomas4019 earned 500 total points
ID: 33447271
wow my bad, this is the link I meant to send, http://groups.drupal.org/node/72553#comment-272429.

pretty much there is no great solution, yes. People moan about the views duplicates problem over and over again and find a few workarounds but there is no one great solution. If you click on your relationship in views, under delta you will see this message ,

"The delta allows you to select which item in a multiple value field to key the relationship off of. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates."

The best solution is probably to merge the multiple rows back into one within flex.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for those that are having major problems with users upload files such as pictures to their profile. The solution is simple and has to do with correcting the directory paths. With some experimenting and testing i got it fixed. Note…
RTL (right to left) web applications aiming for audiences speaking languages like Hebrew or Arabic, are generally more complicated than the same applications aiming for audiences speaking Latin based languages. The main difference lies of course …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question