Access own docType fields in one Model when using another Model
Have made a couple of additions to the Articulate docType. I can't seem to access them in the Articulate master I think because it uses Articulate.IMasterModel as it's model.
The ModelsBuilder put my new fields in Umbraco.Web.PublishedContentModels.
If I put an @using Umbraco.Web.PublishedContentModels then I'm told that Articulate exists in two places Umbraco.Web.PublishedContentModels and my project DLL.
Is it possible to reference both or is there some other way to access extra docType fields that aren't in the compiled Articulate.IMasterModel interface? It's really confusing.
I think Model.GetPropertyValue("") should still work, so you could not reference the PublishedContentModels. Alternatively you could create your own poco as a model (that implements IMasterModel).
As with most of the ModelsBuilder documentation it's totally opaque to me. It possibly means something to a C# MVC ninja. It's just not clear enough as to how you implement it.
So I switched off ModelsBuilder and deleted the App_Data/Models folder and restarted the app. Added a simple bit of code to the Articulate master:-
var pageTitle = string.IsNullOrWhiteSpace(Model.GetPropertyValue("metaTitle").ToString())
And get the expected YSOD: Object reference not set to an instance of an object.
Remember, at the top of the Articulate Master file is:-
Which means "Model" now refers to the compiled Articulate model which knows nothing about my alterations to it's docType.
If I switch on ModelsBuilder, a new Articulate model is built in Umbraco.Web.PublishedContentModels and so we have a conflict.
I always seem to get the sticky end when trying new Umbraco stuff. It costs A LOT of time and money to just then abandon it. I really wish documentation was available with some guidance for the non-ninjas amongst us. One day maybe.......
Access own docType fields in one Model when using another Model
Have made a couple of additions to the Articulate docType. I can't seem to access them in the Articulate master I think because it uses Articulate.IMasterModel as it's model.
The ModelsBuilder put my new fields in Umbraco.Web.PublishedContentModels. If I put an @using Umbraco.Web.PublishedContentModels then I'm told that Articulate exists in two places Umbraco.Web.PublishedContentModels and my project DLL.
Is it possible to reference both or is there some other way to access extra docType fields that aren't in the compiled Articulate.IMasterModel interface? It's really confusing.
Thanks.
Craig
I think Model.GetPropertyValue("") should still work, so you could not reference the PublishedContentModels. Alternatively you could create your own poco as a model (that implements IMasterModel).
Finally you might want to exclude the articulate stuff from the model builder https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/ModelsGenerationConfiguration
Thanks David,
As with most of the ModelsBuilder documentation it's totally opaque to me. It possibly means something to a C# MVC ninja. It's just not clear enough as to how you implement it.
So I switched off ModelsBuilder and deleted the App_Data/Models folder and restarted the app. Added a simple bit of code to the Articulate master:-
And get the expected YSOD:
Object reference not set to an instance of an object.
Remember, at the top of the Articulate Master file is:-
Which means "Model" now refers to the compiled Articulate model which knows nothing about my alterations to it's docType.
If I switch on ModelsBuilder, a new Articulate model is built in
Umbraco.Web.PublishedContentModels
and so we have a conflict.I always seem to get the sticky end when trying new Umbraco stuff. It costs A LOT of time and money to just then abandon it. I really wish documentation was available with some guidance for the non-ninjas amongst us. One day maybe.......
is working on a reply...