Reputation: 11
Hi guys I'm new here also in Umbraco cms. I created a document types and it has a property(media picker)
.
My questions is how can i call themedia picker
into different page.
Let say i will create another page and will call the property that i created from the other page.
Hope someone can help me.
I've search through their website and google but i have no luck to find a better solution.
@if (CurrentPage.HasValue("teaserImage"))
{
var caseStudyImagesList = CurrentPage.CaseStudyImages.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var caseStudyImagesCollection = Umbraco.Media(caseStudyImagesList);
foreach (var caseStudyImage in caseStudyImagesCollection)
{
<img src="@caseStudyImage.Url" />
}
}
Upvotes: 1
Views: 2560
Reputation: 921
You can get the node of the page A from the page B in many ways. For example:
// you can get the A node with its ID if you have it
int idPageA = 1207;
IPublishedContent nodeA = Umbraco.TypedContent(idPageA);
// or maybe by moving through the tree, Model.Content is the typed version of currentpage, so you have intellisense
IPublishedContent nodeA = Model.Content.Parent.Children().Where(x => x.GetPropertyValue<string>("propertyAlias") == "nodeA");
IPublishedContent nodeA = Model.Content.Parent.Children().Where(x => x.Name == "Node A Name");
if (nodeA.HasValue("teaserImage"))
{
var caseStudyImagesList = nodeA.GetPropertyValue<string>(CaseStudyImages).Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var caseStudyImagesCollection = Umbraco.TypedMedia(caseStudyImagesList);
foreach (var caseStudyImage in caseStudyImagesCollection)
{
if(caseStudyImage != null){
<img src="@caseStudyImage.Url" />
}
}
}
Upvotes: 2