Does anyone have any suggestions or links to documentation which outline the best way to create global components in Umbraco?
Currently, I have a master template called Layout.cshtml which bring in the Header and Footer using @Html.PartialAsync.
This displays the header and footer correctly on all pages.
However, as every new page is created, you have to fill in all the elements of the Header and Footer in the CMS for each page that is created: e.g. the links, title, images etc.
Is there a way to create a global header and footer which is the same on every page that is created? I attempted to create a page called "Website Settings" with the global elements but was unsuccessful:
Is there any way to make the data in the "Website Settings" folder globally available on every page?
I have made a doctype called website settings and made it available at root.
I tried accessing the properties using @inherits UmbracoViewPage
ModelBindingException: Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.Home to model type Umbraco.Cms.Web.Common.PublishedModels.WebsiteSettings.
Do you know how you would access the properties of the above content type?
Best Way To Create Global Components in Umbraco
Does anyone have any suggestions or links to documentation which outline the best way to create global components in Umbraco?
Currently, I have a master template called Layout.cshtml which bring in the Header and Footer using @Html.PartialAsync.
This displays the header and footer correctly on all pages.
However, as every new page is created, you have to fill in all the elements of the Header and Footer in the CMS for each page that is created: e.g. the links, title, images etc.
Is there a way to create a global header and footer which is the same on every page that is created? I attempted to create a page called "Website Settings" with the global elements but was unsuccessful:
Is there any way to make the data in the "Website Settings" folder globally available on every page?
Hi Julius,
I would create a doctype called Website which is allowed as root. On this doctype I would then create the Header and Footer properties
In your case the Home node would then be Website doctype, and then the rest would be what ever they need to be.
I have made a doctype called website settings and made it available at root.
I tried accessing the properties using @inherits UmbracoViewPage
ModelBindingException: Cannot bind source content type Umbraco.Cms.Web.Common.PublishedModels.Home to model type Umbraco.Cms.Web.Common.PublishedModels.WebsiteSettings.
Do you know how you would access the properties of the above content type?
try
or
Model.Root()
if you only have a single root nodeThanks for your response,
I ended up going with:
var Home = Umbraco.AssignedContentItem.AncestorOrSelf
and just setting all the Header and Footer properties on the Home Page - I hope this is OK practice though.
is working on a reply...