Render LayoutGrid of child article in umbraco?

*爱你&永不变心* 提交于 2019-12-09 02:07:18

问题


I have a article witch has multiple related article. this related articles have a layout grid. now I want to render this grids below of my main article. I get this related article by this code:

 @{
     var children = Model.Content.GetPropertyValue("relatedArticles").ToString().Split(',');
  }
  @foreach (var child in children) {
      Umbraco.Content(child).GetGridHtml("gridLayout");
  }

but GetGridHtml() function donot work. in umbraco documentation GetGridHtml only is accesible from @CurrentPage. how can I render these grid layout?


回答1:


I finally found my solution by using this method:

@{
     var children = Model.Content.GetPropertyValue("relatedArticles").ToString().Split(',');
 }
 @foreach (var child in children) {
      var data = Umbraco.TypedContent(child);
      @Html.GetGridHtml(data, "gridLayout");
 }


来源:https://stackoverflow.com/questions/42109556/render-layoutgrid-of-child-article-in-umbraco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!