This may be related to [Reverse doesn't work], but it's in some ways the opposite problem, so I'm not sure.
My site uses a non-directed relation, "worked alongside," that connects nodes of type Person. When I create a view to pull titles of related people through the node->relation & relation->node trick, it successfully displays all the people... but then also displays the title of the person whose page we're viewing. (See attached screenshot.) This is especially problematic when there are many such relationships for a given person, as their name appears again for every associated RID.
Directed relations work just fine, because I can specify that I want to base the views relationship around a target. With the non-directed relationship, I don't have that option, and it seems to cross into the relation and then come out at every node on the other side -- including the originating node.
I can't just use node->node because I want to link also to the page of the relation itself, which has more detailed information; I therefore need to pull the RID somehow.
Has anyone else run into to this problem? What workarounds have you used? Is there a way in code to screen for this and prevent it from happening?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 1462068_8.patch | 1.22 KB | chx |
| #2 | improperly_matched_rids_and_endpoints.png | 30.54 KB | benmiller314 |
| #2 | properly_matched_rids,_but_with_repetition_of_source.png | 25 KB | benmiller314 |
| author repeats.png | 47.34 KB | benmiller314 |
Comments
Comment #1
mikran commentedI didn't actually test but I think you can fix this by altering those relationships a little. To get other endpoints of a relation you can specify relationship node->node and for rid and possibly other fields another relationship node->relation.
Comment #2
benmiller314 commentedmikran wrote:
I've tried that, but unfortunately it leads to the old repetition problem, whereby the view matches every related node with every related rid, resulting in N * R items in the list. So while it solves the minor problem, it introduces a much more significant one, in that the rids are no longer properly matched to their corresponding "target" endpoints.
(See attached photos. "Improperly matched" ostensibly shows the same view as in the first post, updated as suggested; I've added the rid as a suffix to clarify what's happening to make the list so long. "Properly matched" shows the old view again, sorted by rid for easier comparison to the new version.)
Comment #3
chx commentedUse a node->relation and a node->node. If you use a node->relation and a relation->node there is nothing that says node1!=node2.
Comment #4
chx commentedGot your problem.
Comment #5
chx commentedComment #6
chx commentedComment #7
chx commentedSo when you add an R->E then we examine whether the Views relationship chain leading to R comes from the same entity type and if so then we provide an option for the exclusion and act on it.
Comment #8
chx commentedThis is what we talked about with dereine, at least I think so. Still need to provide an option for this.
Comment #9
dawehnerI don't believe it, a for loop in drupal code.
Instead of directly accessing the array i prefer to
I'm not 100% sure but i guess this is safe for extra being a string.
You seem to try to match a join, which joins from the entity to the relation data table. Maybe it would be much easier
to read, if you could set a certain flag, so it's just something like
In general #1090432: Allow additional field-to-field conditions with the default views_join handler should help you to be able to not require this dirty hack.
Comment #10
chx commentedThis has been committed with better (but similar) implementation and tests.