OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

Projector and Tokens #4817

Open orchardbot opened 10 years ago

orchardbot commented 10 years ago

neTp9c created: https://orchard.codeplex.com/workitem/20988

ProjectionManager.GetContentQueries function executes ITokenizer.Replace function with empty tokens dictionary and it removes all token expressions from filter state. Therefore it impossible to use tokens in all filters including custom filters.

I think need move execute ITokenizer.Replace to FilterDescriptor.Filter delegate. This will allow to create difference tokens for difference filter. And need add token parameter to IProjectionManager interface. This will allow to set common tokens for all filters.

Code: GetContentQueries(QueryPartRecord queryRecord, IEnumerable sortCriteria, IDictionary<string, object> tokens = null)

var filterContext = new FilterContext { Query = contentQuery, State = FormParametersHelper.ToDynamic(filter.State), Tokens = tokens ?? new Dictionary<string, object>() };

orchardbot commented 10 years ago

@Piedone commented:

Related, duplicate of? https://orchard.codeplex.com/workitem/19693

orchardbot commented 10 years ago

neTp9c commented:

The cause of the problem the same as https://orchard.codeplex.com/workitem/19693 Content tokens not works because tokens dictionary is empty (as I type above).

Need add tokens parameter to IProjectionManager. And set this parameter from Projection Driver.

var tokens = new Dictionary<string, object> { { "Content", part.ContentItem } };