Open orchardbot opened 10 years ago
hkui commented:
@sebastienros commented:
I would suggest instead to create a new token like "AsUser" which would be chained from a Content context and return a User context. This way it could be applied to tokens which are not only from ContentPickerField.
Your string would become Content.CommentedOn.Fields.PageWithComments.SomeUserContentPicker.Content.AsUser.Email
hkui created: https://orchard.codeplex.com/workitem/20430
When using a contentpickerfield, it is not possible to use user properties on the selected user.
For example I have a contentpickerfield that has a user selected, then I want to use this token: Content.CommentedOn.Fields.PageWithComments.SomeUserContentPicker.Content.Email
It doesn't work. The Email-token is assigned to "User", but what's returned on the ContentPickerField is a "Content".
Therefore I modified: Orchard.ContentPicker.Tokens.ContentPickerFieldTokens.Evaluate(): context.For("ContentPickerField")
.Token("Content", (Func<ContentPickerField, object>)(field => field.Ids[0]))
.Chain("Content", "Content", (Func<ContentPickerField, object>)(field => _contentManager.Get(field.Ids[0])))
.Token("User", (Func<ContentPickerField, object>)(field => field.Ids[0]))
.Chain("User", "User", (Func<ContentPickerField, object>)(field => _contentManager.Get(field.Ids[0]).As()))
;
The last Token() and Chain() call are added by me.
Now I can do: Content.CommentedOn.Fields.PageWithComments.SomeUserContentPicker.User.Email
I propose this to be added into the Orchard.ContentPicker module. Or maybe it's already possible by doing it another way, but I'm not sure how. If so, can anyone please tell me?