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

Querying related items based on Content.Id doesn't work #3182

Closed orchardbot closed 9 years ago

orchardbot commented 11 years ago

Padwah created: https://orchard.codeplex.com/workitem/19353

Please see this topic for a description of the problem: http://orchard.codeplex.com/discussions/404343

Steps to reproduce the issue are:

1) Fresh install of Orchard CMS 2) Create a new ContentType called 'Project' and add Title, AutoRoute and Body parts. 3) Create a new ContentTYpe called 'Task' and add Title and Body parts. Also add a new ContentPicker field called 'Project' 4) Create a new Project. 5) Create one or more Tasks setting the project field to the newly created Project. 6) Create a new query called 'Related Tasks' 7) Add a new filter selecting Project:Id's from the Task Content Fields section 8) Select the Equals operator and specify a value of {{Content.Id}} 9) Add a new projection widget to either the default layer or a new layer targetting the project and specify the related Tasks query as the source. 10) View the project and find that no related tasks are displayed. 11) Adjust the query and specify a hardcoded value to that of the project i.e {{15}} 12) View the project and find that it does work.

orchardbot commented 11 years ago

@sebastienros commented:

Fixed in changeset 4140075de93f

orchardbot commented 11 years ago

@sebastienros commented:

The issue was related to the tokenizer behavior. By using {{XYZ}} you are actually asking the tokenizer the exact '{XYZ}' string, and there is no Task with the id '{Content.Id}'. Doubling { or } is escaping the char.

The solution would then be to use {{{Content.Id}}} which in turn will evaluate '{' + actual value of {Content.Id} + '}', but I think this is broken in 1.6 too.

In the 1.x branch where it is fixed you have two new solutions:

orchardbot commented 10 years ago

julrichkieffer commented:

The above repro exactly matches my issue. It appears to be unresolved.

Using both the 1.7.x and 1.x branches, I've tried to create Queries that return child content type records (Project Skill) for the current content type (Project). When hard-coding the content Id to match the Content Picker id of a Project Skill, the projection displays the content record. However, neither notation works: {{{Content.Id}}} nor {#{Content.Id}}.

orchardbot commented 10 years ago

@sfmskywalker commented:

Fixed in changeset 369a1a97a7cee7e1dec0d62ff814d775b86a3ef5