umbraco razor - getting fields from content

前端 未结 5 2055
生来不讨喜
生来不讨喜 2020-12-10 00:30

I have a 6 items of the same content type \"news\", in each item I have a field newsIntro. I want to put the fields in specific pages on another page so I need to target a s

5条回答
  •  既然无缘
    2020-12-10 00:52

    To get fields from content I have used this:

    @{
        var selection = Umbraco.TypedContent(contentId).Children()
                            .Where(x => x.IsVisible())
                            .OrderBy("CreateDate");
    }
    @foreach(var item in selection){
                @item.GetPropertyValue("fieldName1")
                @item.GetPropertyValue("fieldName2")
                @item.GetPropertyValue("fieldName_N")
    }
    

提交回复
热议问题