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
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.
best pratice
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
Iam using it at controller
is working on a reply...