Custom "model" does not exist in the current context
Hi,
sry for this stupid question, but I am fairly new to Umbraco . I am currently editing a uskinned template , and I am wondering what I am doing wrong. I want to create a custom data type, let's call it "mycustomtype".
I create one in the Data Type section without template, name the alias "mycustomtype". I set it under Advanced Page Components. The master template calls a View, which then calls a partial view called component switch. In that view I see there is a switch case with all data types from the template (components). I add another switch case with my custom one:
case mycustomtype.ModelTypeAlias:
@Html.Partial("USNAdvancedPageComponents/mycustomtype", (mycustomtype)Model)
break;
And i get the error on the case line that it doesn't recognize it:
Compiler Error Message: CS0103: The name 'mycustomtype' does not exist in the current context
Do I miss here something obviously or? Do I need to rebuild the models? I thought it get's done automatically when I create a data type? Or is this uskinned template related?
Sry , I am still wrapping my head around umbraco in this short time.
PS. What you are calling a "data type" is actually a "document type" in Umbraco terminology. A "data type" is an instance of a property editor (eg. a textbox). I know, it's confusing, but just so you know in future :)
Custom "model" does not exist in the current context
Hi,
sry for this stupid question, but I am fairly new to Umbraco . I am currently editing a uskinned template , and I am wondering what I am doing wrong. I want to create a custom data type, let's call it "mycustomtype".
I create one in the Data Type section without template, name the alias "mycustomtype". I set it under Advanced Page Components. The master template calls a View, which then calls a partial view called component switch. In that view I see there is a switch case with all data types from the template (components). I add another switch case with my custom one:
And i get the error on the case line that it doesn't recognize it:
Do I miss here something obviously or? Do I need to rebuild the models? I thought it get's done automatically when I create a data type? Or is this uskinned template related?
Sry , I am still wrapping my head around umbraco in this short time.
There are different modes for the Model Builder - some will automatically build models on change, some require manual rebuilding.
There's documentation for the modes here: https://our.umbraco.com/documentation/reference/templating/modelsbuilder/Builder-Modes
PS. What you are calling a "data type" is actually a "document type" in Umbraco terminology. A "data type" is an instance of a property editor (eg. a textbox). I know, it's confusing, but just so you know in future :)
Thx, you are right about document type.
Btw It's PureLive, also when I search the generated model I see the class generated.
I am really not sure what's happening, It's generated, it's spelled right.
Seems like the error is misleading?
Okey, I found the problem.
It was the naming of the model alias. Not sure why or how but the issue is following:
If I created a custom document type and named it's alias customtype, the model would be generated but it would rename it somehow to Customtype.
So when I typed customtype, it didn't exist.
Not sure if this is umbracos fault or the theme itself, but glad I figured it out.
is working on a reply...