Solved

Views and to-many relationship (in service output)

Posted on 2010-08-16
3
683 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Which User Disabled a Module? 11 72
Drupal based website 2 350
Itunes no longer showing podcasts. 3 210
Drupal Custom View 1 127
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 …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now