Umbraco.Content() will return a dynamic DynamicPublishedContent object. Similar to using CurrentPage.
Umbraco.Typed.Content() will return a strongly typed IPublishedContent, similar to using Model.Content.
TLDR: You should always use IPublishedContent. It's more performant and offers intellisense in Visual Studio. Especially awesome when used with Modelsbuilder.
There is a great explanation of why Dynamics should be avoided in the Developers Reference -> Common Pitfalls
If you want some more info see Strongly typed vs Dynamic Content Acces on 24 days in umbraco, it's a few years old but gives a good overview of the difference. Notice that modelsbuilder ships with Umbraco (since version 7.4) so you don't have to install it.
Thanks for clarifying. Sure... I remember the Modelsbuilder, I guess my confusion started when it was added to the core. :-) Now it all makes sense.
You know, sometimes a basic function can be annoyingly confusing.
Difference between content and typedcontent
Just wondering. Whats the difference between TypedContent and Content? Is there any performance difference?
https://our.umbraco.org/documentation/reference/querying/umbracohelper/
Hi there
Umbraco.Content()
will return a dynamicDynamicPublishedContent
object. Similar to usingCurrentPage
.Umbraco.Typed.Content()
will return a strongly typedIPublishedContent
, similar to usingModel.Content
.TLDR: You should always use IPublishedContent. It's more performant and offers intellisense in Visual Studio. Especially awesome when used with Modelsbuilder.
There is a great explanation of why Dynamics should be avoided in the Developers Reference -> Common Pitfalls
If you want some more info see Strongly typed vs Dynamic Content Acces on 24 days in umbraco, it's a few years old but gives a good overview of the difference. Notice that modelsbuilder ships with Umbraco (since version 7.4) so you don't have to install it.
This stackoverflow post is also quite good :)
Hope that helps
All the best
Rune
Umbraco.Typed.Content() is actually Umbraco.TypedContent()
Thanks.
Hi Rune
Thanks for clarifying. Sure... I remember the Modelsbuilder, I guess my confusion started when it was added to the core. :-) Now it all makes sense. You know, sometimes a basic function can be annoyingly confusing.
Thanks :-)
/Peter
True..
And sometimes a basic function can be deceptively complex ;)
You're so very welcome!
is working on a reply...