Using Drupal 6.x w/ Views 6.x-3.0+77-dev to generate relationship-driven link-list

I’m trying to use Drupal (and Views) to generate a list of links to foobar1 from foobar4 if and only if foobar2 node->references foobar3 and is node->referenced by both foobar1 and foobar4.

Here’s some more information:
[TABLE=“class: grid, width: 800, align: left”]
[TR]
[TD]Content Type Nodes[/TD]
[TD]Established References[/TD]
[/TR]
[TR]
[TD]foobar1 (Product Page)[/TD]
[TD]Node->references foobar2[/TD]
[/TR]
[TR]
[TD]foobar2 (Application Page)[/TD]
[TD]Node->references foobar3[/TD]
[/TR]
[TR]
[TD]foobar3 (Database Page)[/TD]
[TD]Makes no references.[/TD]
[/TR]
[TR]
[TD]foobar4 (Organization Page)[/TD]
[TD]Node-references foobar2 and foobar3.[/TD]
[/TR]
[/TABLE]

What I need is to generate title links to foobar1 FROM foobar4, but I don’t want ALL of the foobar4 links… Rather, I just want links to foobar1 if and only if foobar1 node->references the same foobar2 pages that foobar4 references.

Example:
Let’s say we have a product called Widget2000 and it’s managed by OrganizationX. Widget2000 uses a MySQL database and makes use of at least 1 application. (Products are different from applications because Products can be associated with applications but encompass services as well.) So with this in mind, products can be associated with organizations, database servers, applications, etc. So in this example, “Product Pages” constitute a profile page for something a business might provide clients. Think of it like a page that encapsulates “everything you need to know about <X-Y-and-Z>.” What I need some insight on is how to create a Drupal view to output links to Product pages from organization pages if and only if the organization pages node->reference app pages which are node->referenced from the product pages. I’m still unsure if the database node->reference plays a part in this… Originally, I think it may have.

Whatever the case, I figure this will be done using Views’s relationship feature, however, I’m just not sure what needs to be done to do this.

I’ve been able to do this using 2 views (1 that gets all of foobar2’s NIDs and another view that accepts these NIDs as arguments to generate the corresponding field values if they meet the noted criteria, all via “views_embed_view()” within my theme files), but what I want to do is use only 1 view instead because my code would be much more manageable in the future and less confusing.

Any insight into this is not only needed but would be very appreciated. Please let me know if I’m not being clear here and I’ll provide another example.

Well, I just thought I’d update this to maybe shine some light on it from a different angle. If nobody responds, I’ll let it die:

Each Organization (Org) Page is associated with an Application Page using a CCK node->ref field called “app_ref_1”. But then I have a Product Page that also node->references Application Pages using a different node->ref field called “app_ref_2”.

Question: Is it possible to generate links to the respective Product Pages from the Org Page if and only if the respective Product and Org Pages both node->reference the same application(s)? I guess this would be a “third-degree” type of JOIN…?

Here’s what I’ve attempted to do (to no avail):
1.) Indicate that the field I want to output is a Node Title (which will in fact be the Product Page links).
2.) In the arguments, I indicate that I want to provide a default argument of NID (which is to be validated as an NID of type Org Page).
3.) For the filters, it’s pretty straightforward: filter for IS PUBLISHED = TRUE and CONTENT TYPE = Product Page.
4.) Up in the relationships, it gets hairy… The Product Page node references the Application Pages using a different CCK field than the Org pages (it’s a long story why). So I tried to do the following:
A.) Create a relationship with “app_ref_1” field (leaving “Is Required” unchecked). This is the node->ref field that the Org Pages use.
B.) Create a relationship with “app_ref_2” field (leaving “Is Required” unchecked). This is the node->ref field that the Product Pages use.
C.) Every Application Page node references a Database Page, so I created a relationship with “database_field” field but made the two app fields above use this relationship by forcing them to require it. I did this because I felt like it would somehow “relate” the two different app fields, thereby making the entire relationship approach work.

I then went back down to the fields section and in the configuration of the Node Title field I intend to output, I told the field to use the “app_ref_1” relationship because this would be the field that the Org Pages use (the page which I’m trying to output these links on). After clicking Preview (and providing an argument of the Org Page I’ve been using to test with), nothing worked. The query is ran, but no results are shown. This also goes without saying that I indicated in the filters that I wanted it to also use the “app_ref_1” field relationship, thinking that I had to…

So I guess this simply can’t be done in Drupal 6.x using Views 3.x without using 2 views (one to fetch all the app NIDs and another to key off of those app NIDs and subsequently generate links to the respective Product Pages). I just thought I could make this view approach a bit less confusing… Guess not. lol :frowning:

Insights are appreciated.

When dealing with complex relationships it is probably best to write the query manually. The quality of the query generated by views naturally deteriorates as complexity increases. Just because it is possible to do something with a view doesn’t really mean you always should. Especially when it comes to complex cases including multiple associations.

I’ve never had to do that… Do you know which API functions are used for that for D6.x? I think I can probably come up with the query code, but I’m not sure what the API call is to make it all happen (the Drupal way, that is–I don’t want to do some raw approach that doesn’t sanitize everything the way Drupal does).