Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
Is it possible to get an id of the parent block list editor from one of it's child parts.
I need to get a unique id from the block list editor control and reference it in a child content part.
Is this possible?
Thanks
Hi Paul,
The BlockListModel only contains a list of BlockListItem, wich has a ContentUdi and a SettingsUdi.
If you need to reference your BlockListModel, you could send it to your blocks. There is a few ways of doing that.
New Model:
public class ModelAndItem { public BlockListModel Model { get; set; } public BlockListItem Item { get; set; } }
And in the BlockList/Default.cshtml:
@Html.Partial("BlockList/Components/" + data.ContentType.Alias, new ModelAndItem{ Model = Model, Item = block })
Then in your block, you reference it:
var blockListModel = Model.Model; var block = Model.Item;
Add to ViewData:
@Html.Partial("BlockList/Components/" + data.ContentType.Alias, block, new ViewDataDictionary{ { "BlockListModel", Model }})
var blockListModel = this.ViewData["BlockListModel"] as BlockListModel;
Hi Søren,
thanks for the reply, would these options work for Html.GetBlockListHtml (which is what we're using at the moment)
Were you able to solve for this? Im using the same and am trying to get the value of a property from the containing page with no luck.
I'm actually getting an error when trying to create that class as well:
Cannot bind source type ModelAndItem to model type Umbraco.Core.Models.Blocks.BlockListItem.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Block List Editor - Getting parent Id
Hello,
Is it possible to get an id of the parent block list editor from one of it's child parts.
I need to get a unique id from the block list editor control and reference it in a child content part.
Is this possible?
Thanks
Hi Paul,
The BlockListModel only contains a list of BlockListItem, wich has a ContentUdi and a SettingsUdi.
If you need to reference your BlockListModel, you could send it to your blocks. There is a few ways of doing that.
New Model:
And in the BlockList/Default.cshtml:
Then in your block, you reference it:
Add to ViewData:
Then in your block, you reference it:
Hi Søren,
thanks for the reply, would these options work for Html.GetBlockListHtml (which is what we're using at the moment)
Thanks
Were you able to solve for this? Im using the same and am trying to get the value of a property from the containing page with no luck.
I'm actually getting an error when trying to create that class as well:
is working on a reply...