I've added a term reference field to my users called field_user_programmer.

My plan is to fetch nodes where user.term IN node.terms.

View is ready:
Contextual filter: "Content: Has taxonomy term ID"
Argument input: From context/Term ID

In page manager I'm using the context "User" and I wanted to add a relationship "Taxonomy term from User (On User: Program)". When I hit save I get this:

Notice: Undefined index: relationship_entity_from_field:field_user_programmer-user-taxonomy_term_1 in theme_ctools_context_list() (line 230 of C:\wamp\www\emweb_wf\sites\all\modules\ctools\includes\context.theme.inc).

When searching the issue I found this: http://drupal.org/node/1083632. The last notice in the original post seem related to mine.

Let me know if you need more info.

Thanks for an awesome module! I coded my own hack fetching nodes like described above earlier... then I discovered ctools and context! I even bought your book!!

Comments

odegard’s picture

It turned out to be a http://en.wikipedia.org/wiki/User_error#PEBKAC but in my defense, it was a pretty tricky bug to solve.

I crawled the source dsm'ing all variables and function outputs standing between me and the function that returned FALSE instead of a context. It turned out to be field_get_items... a drupal core function.

Thing is, I'm searching for nodes that have common tags to a user. If a user is tagged by TERM-A, I want to find all nodes tagged with TERM-A as well. This is a dashboard-like thing, so I'm running this view for the currently logged in user.

I've created several users with attributes for testing... but my admin user didn't have any terms... so no wonder field_get_items returned FALSE!!

Suggestion: when selecting context user, logged in user etc... how about a dsm() with a message reminding the developer about the potential pitfalls of working with the logged in user context?

It wasn't a complete waste of time though. I got a chance to really dig in to the inner workings of ctools and see how a large and complicated module like this reuses functions (and variable functions). Cool.

merlinofchaos’s picture

Ahh, the logged in user context should probably just perform a full user_load(). I think that would probably solve this.

Letharion’s picture

@merlinofchaos Could you expand on that?

I found myself with this error as well, and based on #2, I looked in plugins/contexts/user.inc, and expected it to pass back only a uid or so, but it looks to me like it always passed back a full $user object from a user_load().

merlinofchaos’s picture

I think what this issue is saying is that when using the logged in user context, the $user object is actually broken. It's taken from global $user which is not a fully loaded user. It may not have things like user fields and profile fields loaded onto it.

Letharion’s picture

Since I needed to get this working, I simply wrote my own specific "term from user" relationship, which works fine. To me this seems to imply that it's the generic entity_from_field.inc relationship that fails to load the full $user, not the user.inc context.

Does that make sense? :)

Countzero’s picture

Could this http://drupal.org/node/1011370 be related to the same problem ?

Basically, the same message is spit, and there is user related stuff as it involves context and Profile2.

jhodgdon’s picture

Status: Active » Closed (duplicate)

This issue is a duplicate of #1633452: Notice: Undefined index: relationship_entity_from_schema:uid-user-node_1, which I'm about to add more information to.