Copied to clipboard

Flag this post as spam?

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


  • Meni 273 posts 530 karma points
    Jan 30, 2023 @ 00:03
    Meni
    0

    How to get node properties in Umbraco 11

    Hi,

    I have a Document type in my website - NewsPage that have the following properties: title subTitle, articleImg, etc.

    In my 7.15.7 website I display the title as follow:

    <a href="@Imaging_pagesToList.Last().Url">
                            <h3 class="MainNewsTitle-1">
                                 @Imaging_pagesToList.Last().title 
                            </h3>
                        </a>
    

    which doesn't work in Umbraco 11.

    When migrate the code base to 11.1 I tried:

    <h3 class="MainNewsTitle">@Model.Value("title")</h3>
    

    or in other place

    <h3>@photonics_pagesToList.Last().Value("title")
    

    but it didn't display nothing.

    So I tried:

    <h3 class="MainNewsTitle">@Model.Name</h3>
    
    <h3>@photonics_pagesToList.Last().Name
    

    and when I'm using .Name , instead of Value("title") I do get the value of the title

    But I'm not understand: I don't have property in PageNews Document Type for Name ?? I have for title !

    so why it displays the title when I'm using @Model.Name ??

    So why bother and having property for title?

    I'm confused

    Please advise.

    Thanks

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jan 30, 2023 @ 09:44
    Huw Reddick
    101

    Hi Meni.

    Not sure exactly what you are doing, but Name is a standard property which all nodes will have, and unless you set them to be the same should not have the same value as your (custom) title property.

    e.g. Example node enter image description here

    In the template you add the following

    <h1>@Model.Name</h1>
    <h2>@Model.Value("title")</h2>
    <h3>@Model.Value("subTitle")</h3> 
    

    Which should give you an out put of

    Test page

    Page Title

    sub title

  • Meni 273 posts 530 karma points
    Jan 30, 2023 @ 18:55
    Meni
    0

    Hi, thanks. Seems I had an issue with the document types in the migration. I took a fresh version of the upgraded v11 database , deleted the Generic properties group from the document type and created again and saved and now Value(“title”) works. Thanks again for your help

Please Sign in or register to post replies

Write your reply to:

Draft