Navid_pdp11
Navid_pdp11

Reputation: 4012

Render LayoutGrid of child article in umbraco?

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?

Upvotes: 1

Views: 315

Answers (1)

Navid_pdp11
Navid_pdp11

Reputation: 4012

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");
 }

Upvotes: 1

Related Questions