I'm wondering what bits are not working for you and I'm thinking that In Umbraco 7
var home = Umbraco.Content(1057);
will return a 'dynamic' object representation of your homepage with id 1057
which allows you to read property values like home.pageTitle etc
However in Umbraco 8 'dynamics' have been removed, and now Umbraco.Content will return a strongly typed IPublishedContent object representing the homepage
eg
IPublishedContent home = Umbraco.Content(1057);
// and you can use the Value property to read the value of a property!
var pageTitle = home.Value
You are writing out properties from the 'home' node you are retrieving using 'dynamic' eg
@home.FooterAddress
But dynamics has been removed in V8
Now Umbraco.Content returns an instances of IPublishedContent
To read a property from IPublishedContent you would need to do this instead:
@home.Value("footerAddress")
Instead of @home.FooterAddress
So I suspect the errors you are seeing are not connected to retrieving the homepage via Umbraco.Content but instead trying to write out these properties in a dynamic format.
If you update all of these instances that use dynamic approach to use .Value("alias") approach, do you find that your template renders correctly?
If you are not keen on the .Value approach then the alternative is to setup ModelsBuilder on your site to generate a poco c# class representation of the DocumentType that would then allow you to have
@inherits UmbracoViewPage<MyHomePageDocType>
and allow you to write
@Model.FooterAddress
but you'll need to configure Modelsbuilder, as per the documentation I linked to in my first reply!
Umbraco 8 Content from other pages
Hello,
I am in the process of upgrading from Umbraco 7 to 8.
In 7 i am using
To bring content throughout the whole site, like footer details.
For some reason this process does not seem to work as expected in Umbraco 8.
What is the best way to do this now?
Hi Michael
I'm wondering what bits are not working for you and I'm thinking that In Umbraco 7
will return a 'dynamic' object representation of your homepage with id 1057
which allows you to read property values like
home.pageTitle
etcHowever in Umbraco 8 'dynamics' have been removed, and now Umbraco.Content will return a strongly typed IPublishedContent object representing the homepage
eg
IPublishedContent home = Umbraco.Content(1057); // and you can use the Value property to read the value of a property! var pageTitle = home.Value
You can also run Umbraco using Modelsbuilder, https://our.umbraco.com/documentation/reference/templating/modelsbuilder/ and then you can have doc type specific models generated and can write something like
regards
marc
Hi Marc,
Thank you for the reply.
I will give it a try.
Hi Marc,
Still not doing what I need.
Here is my master page code.
Thanks
Hi Michael
You are writing out properties from the 'home' node you are retrieving using 'dynamic' eg
@home.FooterAddress
But dynamics has been removed in V8
Now Umbraco.Content returns an instances of
IPublishedContent
To read a property from IPublishedContent you would need to do this instead:
Instead of
@home.FooterAddress
So I suspect the errors you are seeing are not connected to retrieving the homepage via Umbraco.Content but instead trying to write out these properties in a dynamic format.
If you update all of these instances that use dynamic approach to use .Value("alias") approach, do you find that your template renders correctly?
If you are not keen on the .Value approach then the alternative is to setup ModelsBuilder on your site to generate a poco c# class representation of the DocumentType that would then allow you to have
and allow you to write
but you'll need to configure Modelsbuilder, as per the documentation I linked to in my first reply!
regards
marc
is working on a reply...