Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Robert Mroch 4 posts 85 karma points
    Jun 22, 2018 @ 19:31
    Robert Mroch
    0

    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:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.MoneyBackGuarantee>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
    @Html.Partial("~/Views/Partials/SectionHeader.cshtml")
    
    <section class="section">
        <div class="container">
            @Umbraco.Field("bodyText")<br/>
                    <a class="button button--border--solid" href="@Model.Content.HeroCTALink.Url">
                @Model.Content.HeroCtacaption
            </a>
        </div>
    </section>
    

    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?)
    

    Any idea what I might be doing wrong?

    Thanks!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 23, 2018 @ 07:46
    Jan Skovgaard
    100

    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

  • Robert Mroch 4 posts 85 karma points
    Jun 25, 2018 @ 12:23
    Robert Mroch
    0

    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?

  • Robert Mroch 4 posts 85 karma points
    Jun 25, 2018 @ 16:30
    Robert Mroch
    1

    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?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 25, 2018 @ 17:42
    Jan Skovgaard
    0

    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

  • Nigel Wilson 944 posts 2076 karma points
    Jun 25, 2018 @ 00:51
    Nigel Wilson
    0

    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

  • Robert Mroch 4 posts 85 karma points
    Jun 25, 2018 @ 12:01
    Robert Mroch
    0

    Thanks for the response.

    I click on Developer | Models Builder and I see this:

    Models Builder

    ModelsBuilder is enabled, with the following configuration:

    • The models factory is enabled.
    • The API is neither installed nor enabled. External tools such as Visual Studio cannot use the API.
    • PureLive models are enabled.
    • Models namespace is Umbraco.Web.PublishedContentModels.
    • Static mixin getters are enabled. The pattern for getters is "Get{0}".
    • Tracking of out-of-date models is not enabled.

    I do not see an option for Generate Models. Is there anything else which might cause this?

  • Nigel Wilson 944 posts 2076 karma points
    Jun 25, 2018 @ 17:05
    Nigel Wilson
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft