Skip to content

Commit

Permalink
Fixed block group items for posts. Fixes #577
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Apr 26, 2019
1 parent 02f8130 commit 3a40344
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions data/Piranha.Data.EF/Repositories/PostRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,19 @@ private void Process<T>(Data.Post post, T model) where T : Models.PostBase
{
if (post.Blocks.Count > 0)
{
var blocks = post.Blocks
.OrderBy(b => b.SortOrder)
.Select(b => b.Block)
.ToList();
model.Blocks = _contentService.TransformBlocks(blocks);
foreach (var postBlock in post.Blocks.OrderBy(b => b.SortOrder))
{
if (postBlock.ParentId.HasValue)
{
var parent = post.Blocks.FirstOrDefault(b => b.BlockId == postBlock.ParentId.Value);
if (parent != null)
{
postBlock.Block.ParentId = parent.Block.Id;
}
}
}
model.Blocks = _contentService.TransformBlocks(post.Blocks.OrderBy(b => b.SortOrder).Select(b => b.Block));

}
}
}
Expand Down

0 comments on commit 3a40344

Please sign in to comment.