如何获得umbraco 7的房产价值

问题描述 投票:0回答:1

嗨,大家好,我也是Umbraco cms的新人。我创建了一个文档类型,它有一个property(media picker)。我的问题是如何将media pickerin调用到不同的页面。假设我将创建另一个页面,并将调用我从其他页面创建的属性。希望可以有人帮帮我。我搜索他们的网站和谷歌,但我没有运气找到更好的解决方案。

@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"  />
    }
}
umbraco umbraco7
1个回答
2
投票

您可以通过多种方式从页面B获取页面A的节点。例如:

// 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"  />
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.