umbraco razor - getting fields from content

前端 未结 5 2063
生来不讨喜
生来不讨喜 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:56

    First, get an IPublishedContent object from the TypedContent method and then use GetPropertyValue to retrieve the value of the field.

    @{
      int nodeId = 1720;
      IPublishedContent contentNode = Umbraco.TypedContent(nodeId);
      var newsIntro = contentNode.GetPropertyValue("newsIntro");
    }
    
    

    @newsIntro

提交回复
热议问题