Thanks for this package, it looks pretty awesome.
I saw you created something to make the IPublishedElement working too.
Unfortunately, I cannot get it to work.
My ActionResult is this:
public ActionResult Render(string property) {
var result = new List<BaseBlockModel>();
var mapper = new UmbracoMapper();
foreach (var publishedElement in CurrentPage.Value<IEnumerable<IPublishedElement>>(property))
{
if (publishedElement.ContentType.Alias == "BlockCases")
{
var viewModel = new BlockCases();
var publishedContent = publishedElement as IPublishedContent;
mapper.Map(publishedElement, viewModel);
result.Add(viewModel);
}
}
return PartialView(result);
}
And my model looks like this:
public class BlockCases : BaseBlockModel {
public BlockCases()
{
}
[PropertyMapping]
public string Title { get; set; }
[PropertyMapping]
public HtmlString Text { get; set; }
[PropertyMapping]
public Link Cta { get; set; }
public List<SquareItemViewModel> Cases { get; set; }
[PropertyMapping]
public string OverviewText { get; set; }
/// <summary>
/// todo
/// </summary>
public string OverviewLink { get; set; }
}
Please excuse the bad naming and lack of descriptions. It's not my code and I'm first getting it to work, then refactor.
Removing the [PropertyMapping] or the empty constructor doesn't change anything.
IPublishedElement-mapping Umbraco 8.1
Hi Andy,
Thanks for this package, it looks pretty awesome. I saw you created something to make the IPublishedElement working too.
Unfortunately, I cannot get it to work. My ActionResult is this:
And my model looks like this:
Please excuse the bad naming and lack of descriptions. It's not my code and I'm first getting it to work, then refactor.
Removing the [PropertyMapping] or the empty constructor doesn't change anything.
Could you help me out? Thanks in advance!
Oh, btw:
Does work, but I have different doctypes, so I cannot map them to a generric type.
Just from a quick look, can you confirm your variable
publishedContent
, when castas IPublishedContent
, isn't null?Andy
Hi Andy,
I am sorry, I should have removed that line. I am loading in the publishedElement, not the publishedContent.
My model contains: public List
I am now using
on that property and now it seems to work.
Thanks!!
Hi Sibren,
Im having the same issue, could you share your working code so I can see where im going wrong?
Lewis
is working on a reply...