Master Detail Relationship - Passing ID of Parent to a Projector Widget

Topics: General
Dec 22, 2012 at 7:36 PM
Edited Dec 22, 2012 at 7:37 PM

I am modelling a master-detail (parent-child) relationship using two custom content types. The child has a content-picker field that holds the content id of the parent.

On the page where I am viewing the parent content item, I have projection widget containing content items of the child type which I want to filter on the content picker field id.

So far, so good. I have the widget built and it will filter the correct child content items if I set the parent id manually. However, I need a token for the parent id that I can pass to the flter in the projector widget. Is anyone able to help?

The parent item has the same context as the page (i.e. the parent id is in the page's url).  

Dec 23, 2012 at 6:27 AM

Widgets can't know what is displayed in the main content zone. You need the main content to prepare data in a place that the widget will be able to use. The Layout object, or HttpContext are both such places that you can use for that.

Dec 23, 2012 at 4:10 PM
Edited Dec 23, 2012 at 4:10 PM

Thanks, Bertrand. :) Can you point me in the direction of an example, please? I want to create a parameter in the layout (wrapper) and bind it to the filter value. I'd like to know what the filer value looks like (i.e. is it a token etc.). I've been through all the video presentations and can only see the filter value being bound to constants or tokens.   

Dec 28, 2012 at 8:28 AM

You may have to build your own filter.

Apr 29, 2013 at 1:40 PM
This is a bit late for the above request, but we solved a similar issue by adding the Rewrite Rules module to get a querystring from the url of the page. The route for the parent item was configured to contain its content id as part of the url. This id becomes a parameter in the query string which can be used in the projection query as a token ({Request.QueryString:ParamName}).