Howdy all,
I'm struggling with trying to generate a complicated View. Let me try explaining it and see if anyone can help.
So, my website RobotBox has the following:
Node: Robot
Node: User Profile
Node: Robot Club
Users create Robots.
Users create a User Profile (via Node Profile module and APK)
User Profiles have a field, Node Reference, to a Robot Club (via Node Relationships module)
Got it?
Now, here's what I want to do:
I want to create a view that shows all the robots created by all the users that belong to a certain club.
e.g. Dr_Soong has created two Robot nodes, "Lore" and "Data". Dr_Soong has a Node Profile and references the club "Lonely Mad Scientists". Now, when I visit the Lonely Mad Scientists club node, I want a list of the all the robots - Lore and Data, in this case.
The problem is that I can't seem to do this via Views.
I tried creating a view with the Club NID as the argument and a "node relations" reference, but that only brings in the Node Profiles, not the users, much less the user's nodes.
So, I'm stuck and not sure what to do about it.

Comments
Views Default Arguments from Context FTW?
If I had this to do I'd probably use Views Default Arguments from Context module and a custom code snippet that used context_set to stash a comma separated list of UID's in the group. Once that was done I add a User: UID argument to my view, select provide default argument, select active context, set the context and attribute (from my context_set()) and check "allow multiple terms per argument". Then add a published and node type filter and you should be good to go.
http://www.centurionwebdev.com/content/taking-views-next-level-smart-arg...
This sounds like the sort of
This sounds like the sort of thing that Organic Groups does out of the box. Any reason not to use OG? (group == robot club)
otherwise - relationships through the node/user references is how I've always managed to do these sorts of things. If you have a devel site or a DB dump to share, maybe we can figure out a solution for you.
Sheena, good call on OG. I
Sheena, good call on OG. I hadn't thought of that. I'll start to wade through all the documentation. I'm worried it might be a bit of overkill for now.
There appears to be several similar posts in the Node Relationships issues queue, and the ruling opinion is that to get a get a list of UIDs/NIDs for the backreferences, you'll need to do it in the Views theme: http://drupal.org/node/532714
I might pop on IRC this afternoon and chat with whoever's there about this. Hopefully a OG master will be there :)
You don't have to do it in
You don't have to do it in the template, but that's likely the way that will require the least programming. However, you won't be able to filter out users with no robots in the view if you do all the work in the template.
The data you want can be retrieved in a query, and if you can do it in a query then you can do it in views (with varying levels of work). I'm not sure how far you can take views relationships, but it would be the first place I look.
If I were writing the query by hand, I'd do something like this:
Select username, user_bio, group_concat(robot_nid) from A inner join B ... group by uid;
In the query you can eliminate any users without robots, and get all the needed nids. Then in the template you can just explode on comma and do a foreach with node_load.
Ken Winters
Are you looking to just have
Are you looking to just have a list of robots or do you want each to be associated with a user
Eklipse Interactive
Big_Balou, I was looking to
Big_Balou,
I was looking to generate a list of robots.
So, for instance, this page would have a list of members, along with a list of member's robots: http://beta.robotbox.net/club/triangle-amateur-robotics-club
What path did you decide? If
What path did you decide? If you go with OG I'd be interested in learning that with you. We could meet up at the Gades house or something. (that way wifey's can play while we... play!)
To anyone looking to play with OG
Acquia is working on a new distro - Drupal Commons - which is basically beefed up OG geared towards intranets. You might want to wait a couple weeks until they get the beta up and play with that instead.
http://acquia.com/products-services/drupal-commons
Please post when Drupal Commons is ready
Would you please post when you see that Drupal Commons ready? I've installed Open Atrium and was getting ready to start playing with it. From what I see, I should skip Open Atrium and wait for Drupal Commons.
Judy Hallman
Judy, From the little bit
Judy,
From the little bit I've played around with Open Atrium (not much), I'd say Drupal Commons is more straight forward and easy to understand, but Open Atrium may be a bit more customizable.
Get an account on the beta site and play around a bit: http://commons.acquia.com/
I'll post again here when it's released, shouldn't be much longer :)
Commons is
Commons is launched!
http://acquia.com/products-services/drupal-commons
A CCK only suggestion
If you were going to do this without OG... which is pretty useful now already, btw.
For OG I'd set my Content types up like this:
Group (or what ever content type(s) you want as a "Group Node" )
Robots (Set this as a type that can be "posted" to Groups)
Assuming the owner of the Robot nodes is the the designer, (could be a CCK field), the group views module that comes with OG should give you automatic relationships to use in creating different views. E.g. there is a view type for group posts and there are a bunch of extra things in the fields drop-down.
If you are doing this with standard nodes, I'd try the following context type setup:
User (standard Drupal)
Group (Context type)
Robot (Context type)
Designer: CCK User Reference (unless the Node owner is the same...)
Group Id(s): A single or multiple CCK Node Reference to related group node(s)
Create the View based on nodes and filter it to published nodes of the Robot type..
Define references to the User and Group.
Add the fields:
Content User (you may need to use a reference if it's based on the "Designer" )
Group Name (Title?) using the Group reference.
Any fields you need from the robot (or others).
From this, you should be able to make sub-pages/block of this core view. E.g. to generate a full list page, use sorting and group by options to generate a list of groups/user/robots or user/group/robots.
To list a specific user's items, add a user name/id argument and use this to filter by.
And many variations on this...
FYI - I know there are a bunch of good tutorial vid's on references out there.. just google them.