It would depend on how Document Type B content relates to Document Type A content in your Umbraco Content Tree.
If Document Type B is a child of Document Type A, then you could read the property from the 'Parent' property in Document Type B's template
eg
var typedMediaPickerSingle = Model.Parent.Value<IPublishedContent>("featuredBanner");
if Document Type B is a descendant of Document Type A, then you could use a recursive fallback to read the property:
var typedMediaPickerSingle = Model.Value<IPublishedContent>("featuredBanner", fallback: Fallback.ToAncestors);
If Document Type B is not in anyway consistently related to Document Type A in the Content Tree, then it will be a case of 'traversing' to that particular node, and retrieving it as IPublishedContent to be able to read it's properties eg. perhaps starting at the root of the site, perhaps there is only one page of DocType A... then something like this might work:
var docTypeA = Umbraco.ContentAtRoot().Descendants().FirstOrDefault(f=>f.ContentType.Alias == "documentTypeA"));
var typedMediaPickerSingle = docTypeA.Value<IPublishedContent>("featuredBanner");
Using Media picker in another template
Hi all,
My mind has gone blank can someone point me in right direction.
If I have a media picker in doc type A how can I render the image in Doc Types B template?
I use the following code;
Which works fine if I wanted to use in in Doc Type A template, but not doc type B template?
Thanks
Hi Matt
It would depend on how Document Type B content relates to Document Type A content in your Umbraco Content Tree.
If Document Type B is a child of Document Type A, then you could read the property from the 'Parent' property in Document Type B's template
eg
if Document Type B is a descendant of Document Type A, then you could use a recursive fallback to read the property:
If Document Type B is not in anyway consistently related to Document Type A in the Content Tree, then it will be a case of 'traversing' to that particular node, and retrieving it as IPublishedContent to be able to read it's properties eg. perhaps starting at the root of the site, perhaps there is only one page of DocType A... then something like this might work:
regards
Marc
is working on a reply...