Copied to clipboard

Flag this post as spam?

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


  • Nicholas 3 posts 83 karma points
    Aug 17, 2020 @ 04:26
    Nicholas
    0

    How do i get Alias Text in the DocumentType

    Hi all, I'm having trouble getting the label from the alias. It doesn't have the property for "Name". Was checking out previous solution that's should have prop.Name but i tested all the solution debugging in the solution it doesn't have the Name property

    The method i have tried as:-

        var home = (Home)Model.Root();
        foreach (var properties in Model.Properties) { }
    

    It doesn't consist of the Name Properties enter image description here

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 17, 2020 @ 10:31
    Steve Morgan
    100

    Hi,

    I don't believe you can get that from the IPublishedProperty.

    I think you'll have to use the content service - note this is a database hit most likely so don't use this if you need performance. Out of interest why are you trying to get these labels on the front end?!

     var contentTypeService = Services.ContentTypeService;
        IContentType contentType = contentTypeService.Get("home");
    
        var propertyTypes = contentType.PropertyTypes;
    
        foreach (var curPropertyType in propertyTypes)
        {
            <p>@curPropertyType.Alias - @curPropertyType.Name</p>
    
            <hr />
        }
    
  • Nicholas 3 posts 83 karma points
    Aug 17, 2020 @ 23:06
    Nicholas
    0

    The reason i want it because we don't want to hardcode that section title. User can change through the label for it without having extra column field for that particular section example: Products as Label and the value is list of links. Thank for the solution will think a way that to not ping to database everytimes

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Aug 18, 2020 @ 07:11
    Steve Morgan
    0

    It sounds like what you actually want is a separate text field and a nested content item which is a list of links.

    Using the doc type name here is inappropriate and would be bad for performance.

    Doctype Aliases and names are just for the backoffice.

  • Nicholas 3 posts 83 karma points
    Aug 18, 2020 @ 07:35
    Nicholas
    0

    Understand that just that thinking is possible using that label rather than create 1 more textfield for that title. Anyway thank for you helps on this. For now i will be creating the textfield for user to input in then for the section title.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies