Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Views and to-many relationship (in service output)

Posted on 2010-08-16
3
Medium Priority
?
694 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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