Does that mean that articulateMasterModel isn't a IMasterModel but something else.
A RenderModel should always have a non-null Content property so perhaps just go with var articulateMasterModel = (IMasterModel)model.Content;. You'll at least see why the cast is invalid that way.
You'll need to explain more about what this controller you have written is, what is it?
I assume this page is not an articulate page, in that case model.Content is just your normal IPublishedContent for the page rendering.
If you want to lookup an IMasterModel for Articulate, you need to go lookup the Articulate root node - using normal Umbraco content queries. Once you have that you can new-up an IMasterModel instance such as the generic MasterModelhttps://github.com/Shazwazza/Articulate/blob/master/src/Articulate/Models/MasterModel.cs , i.e. new MasterModel(articulateRootNode);
Get Recent Posts From inside MVC controller
Hi Guys,
I'm trying to do something that is fairly simple, but as I have never used Articulate before I'm struggling.
I want to get the latest blog post, this is what I have got so far.
articulateMasterModel ends up being null - what is the correct way to initialize it?
Does that mean that
articulateMasterModelisn't aIMasterModelbut something else.A
RenderModelshould always have a non-nullContentproperty so perhaps just go withvar articulateMasterModel = (IMasterModel)model.Content;. You'll at least see why the cast is invalid that way.You'll need to explain more about what this controller you have written is, what is it?
I assume this page is not an articulate page, in that case
model.Contentis just your normal IPublishedContent for the page rendering.If you want to lookup an
IMasterModelfor Articulate, you need to go lookup the Articulate root node - using normal Umbraco content queries. Once you have that you can new-up anIMasterModelinstance such as the genericMasterModelhttps://github.com/Shazwazza/Articulate/blob/master/src/Articulate/Models/MasterModel.cs , i.e.new MasterModel(articulateRootNode);Thanks, Shannon Exactly what I was looking for!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.