Copied to clipboard

Flag this post as spam?

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


  • Li JC 9 posts 89 karma points
    6 days ago
    Li JC
    0
    Hello everyone,
    
    Iam trying to get some data from the documention type. 
    
    I have found this solution :
    
    umbracoHelper.Content(2921).GetPropertyValue<string>("aDGroupName");
    
    But is it best pratice? IT is fine to write "aDGroupName" because it is a alias that i haved created. But what about the "umbracoHelper.Content(2921)", because i am hardcoding the id. But what can i do alternativ?
    
    thx
    
  • Alex Skrypnyk 5392 posts 19944 karma points MVP 3x admin c-trib
    6 days ago
    Alex Skrypnyk
    0

    Hi Li JC

    What Umbraco version are you using?

    It's better to use Models Builder, check out docs - https://our.umbraco.com/documentation/reference/templating/modelsbuilder/

    With Models Builder you will have IntelliSense so you don't need to hardcode a property alias.

    Another question to you, where do you use this code? If it's in view or Umbraco controller you don't need to instantiate UmbracoHelper class, the instance is accessible just by Umbraco.

    Thanks,

    Alex

  • Li JC 9 posts 89 karma points
    6 days ago
    Li JC
    0

    Iam using it at controller

Please Sign in or register to post replies

Write your reply to:

Draft