I am very new to Umbraco. I want to create a new page called Money Back Guarantee. I created a Document Type, In the Settings, called Money Back Guaranee with one tab called Contents. I have four properties in that tab; Page Title (pageTitle-Textbox), Body Text (bodyText-Textarea), Call To Action Caption (heroCTACaption-TextBox), Call To Action Link (heroCTALink-Content Picker). This created one template called Money Back Guarantee.
I assigned that template to the Master template and gave it the following code:
I crated the page of that type but I get an error on the Model.Content.HeroCTALink.Url:
Compiler Error Message: CS1061: 'Umbraco.Web.PublishedContentModels.MoneyBackGuarantee' does not contain a definition for 'HeroCTALink' and no extension method 'HeroCTALink' accepting a first argument of type 'Umbraco.Web.PublishedContentModels.MoneyBackGuarantee' could be found (are you missing a using directive or an assembly reference?)
Judging by the error message you receive I think you're referencing the wrong alias on your document type. Please note than when you write the name of your property the alias, which is what is what should be referenced in your code, will be autogenerated and it might change the casing. So I'd say double check the alias and see if it's matches what you're typing in the view.
Happy to see you managed to figure it out - Umbraco will Pascal case the alias. So if you have a property name like "My property name" the alias will be "MyPropertyName". If you want it to be cased like "MyPROPERTYName" then it's possible to rename the alias but I don't see the point in doing that most of the time. There can perhaps be some edge cases where it makes sense though.
But usually I think it's rather easy to remember how to call the proper alias but that's easy for me to say when I have many years of experience of course. When one is just starting out it can be really confusing.
I'm also blessed with having [ReSharper][1] installed in my Visual Studio, which provides me with Intellisense so I can dot through the model and the options I have available to me.
If you edit your views etc. using the editor in the Umbraco backoffice there is no smart intellisense, which can help you figure it out by dotting through the model.
If you're using Visual Studio then there is a bit of intellisense but i requires that you setup and run the project using it of course and then I think it also depends on the Models builder settings since the default setting "Pure live" will not be compiled until runtime so the possible values will not be known and therefore intellisense won't work with this setting for instance.
At my current job we have our own Umbraco Baseline where intellisense works out of the box so I don't have to worry about it (I'm a frontend developer) so currently I don't know, which setting to use when using the Models builder out of the box for having better intellisense unfortunately. But some of the other nice and highly skilled people in here can probably tell you more about it :)
I hope this clarifies things a bit? Happy umbracoing!
Could it be a case of content models not being published?
When making document types and if your "Umbraco.ModelsBuilder.ModelsMode" is set to Dll in the web.config you need to generate your document type models each time you make a change to a document type.
If so go to the developer section, then the Models Builder section and click the Generate Models button.
Hi Robert - no there is nothing for you to do on the models section - if you have the setting set to Dll in the web.config you would see a button - being set to PureLive means this idea isn't necessary. And in any case Jan was correct...
Hero CTA Link error
Hello,
Umbraco version 7.10.4
I am very new to Umbraco. I want to create a new page called Money Back Guarantee. I created a Document Type, In the Settings, called Money Back Guaranee with one tab called Contents. I have four properties in that tab; Page Title (pageTitle-Textbox), Body Text (bodyText-Textarea), Call To Action Caption (heroCTACaption-TextBox), Call To Action Link (heroCTALink-Content Picker). This created one template called Money Back Guarantee.
I assigned that template to the Master template and gave it the following code:
I crated the page of that type but I get an error on the Model.Content.HeroCTALink.Url:
Any idea what I might be doing wrong?
Thanks!
Hi Robert and welcome to Our and Umbraco :)
Judging by the error message you receive I think you're referencing the wrong alias on your document type. Please note than when you write the name of your property the alias, which is what is what should be referenced in your code, will be autogenerated and it might change the casing. So I'd say double check the alias and see if it's matches what you're typing in the view.
I hope this makes sense? :)
/Jan
Hello,
I have the alias heroCTALink and it is a Content Picker property. In the template I have:
href="@Model.Content.HeroCTALink.Url"
Is that correct?
I messed around with the case sensitivity until I guessed what I should put. It ended up being: HeroCtalink
Is there a better way than just guessing what Umbraco assigns for the name?
Hi Robert
Happy to see you managed to figure it out - Umbraco will Pascal case the alias. So if you have a property name like "My property name" the alias will be "MyPropertyName". If you want it to be cased like "MyPROPERTYName" then it's possible to rename the alias but I don't see the point in doing that most of the time. There can perhaps be some edge cases where it makes sense though.
But usually I think it's rather easy to remember how to call the proper alias but that's easy for me to say when I have many years of experience of course. When one is just starting out it can be really confusing.
I'm also blessed with having [ReSharper][1] installed in my Visual Studio, which provides me with Intellisense so I can dot through the model and the options I have available to me.
If you edit your views etc. using the editor in the Umbraco backoffice there is no smart intellisense, which can help you figure it out by dotting through the model.
If you're using Visual Studio then there is a bit of intellisense but i requires that you setup and run the project using it of course and then I think it also depends on the Models builder settings since the default setting "Pure live" will not be compiled until runtime so the possible values will not be known and therefore intellisense won't work with this setting for instance.
At my current job we have our own Umbraco Baseline where intellisense works out of the box so I don't have to worry about it (I'm a frontend developer) so currently I don't know, which setting to use when using the Models builder out of the box for having better intellisense unfortunately. But some of the other nice and highly skilled people in here can probably tell you more about it :)
I hope this clarifies things a bit? Happy umbracoing!
/Jan
Hi Robert
Could it be a case of content models not being published?
When making document types and if your "Umbraco.ModelsBuilder.ModelsMode" is set to Dll in the web.config you need to generate your document type models each time you make a change to a document type.
If so go to the developer section, then the Models Builder section and click the Generate Models button.
Cheers
Nigel
Thanks for the response.
I click on Developer | Models Builder and I see this:
Models Builder
ModelsBuilder is enabled, with the following configuration:
I do not see an option for Generate Models. Is there anything else which might cause this?
Hi Robert - no there is nothing for you to do on the models section - if you have the setting set to Dll in the web.config you would see a button - being set to PureLive means this idea isn't necessary. And in any case Jan was correct...
Nice work - trust you are enjoying using Umbraco
Nigel
is working on a reply...