I need to create a footer with own document type. The person i am creating this site to, should only edit the footer once, and then be applied to all pages.
My idea was to make a footer document type. Add that document type to a partial view and then i my Master.cshtml file add my partial footer view.
The template, and partial view will always be executed in the context of the current page the person is visiting.
What I can't tell from your example above is how you are getting a reference to your footer content.
Also I'm not sure if you've created a 'footer' composition and added it to all your document types, or just the Homepage, or whether you've created a specific footer 'document type' and so you have a node in the content tree that contains the 'footer' content.
So if you have a site with structure
Home
- About Us
- News
- Contact Us
- Etc
Settings
- Footer
Then in your master page template, you would need to get a reference to the 'Footer' page, and pass this to the PartialFooter partial view, so this partial always worked with the Footer content.
eg
<footer class="section--themed">
<div class="container">
<div class="row">
<div class="col-md-12 ta-center">
@{
//use Xpath based on the alias's of each document type in the tree
IPublishedContent footerContent = Umbraco.TypedContentSingleAtXPath("/root/settings/footer");
}
@Html.Partial("~/Views/Partials/PartialFooter.cshtml",footerContent )
</div>
</div>
</div>
</footer>
Your PartialFooter view should 'expect' an object of IPublishedContent
@inherits UmbracoTemplatePage<IPublishedContent>
@{
var apropertyfromfooter = Model.Content.GetPropertyValue<string>("propertyfromFooter");
}
<h2>@apropertyfromfooter</h2>
You could also save this partial executing on every page by using
Dynamic CMS Footer, with own document type
I need to create a footer with own document type. The person i am creating this site to, should only edit the footer once, and then be applied to all pages.
My idea was to make a footer document type. Add that document type to a partial view and then i my Master.cshtml file add my partial footer view.
Something like
However, this doesn't work.
Any ideas? and feel free to ask for more information.
Hi Magnus
The template, and partial view will always be executed in the context of the current page the person is visiting.
What I can't tell from your example above is how you are getting a reference to your footer content.
Also I'm not sure if you've created a 'footer' composition and added it to all your document types, or just the Homepage, or whether you've created a specific footer 'document type' and so you have a node in the content tree that contains the 'footer' content.
So if you have a site with structure
Home - About Us - News - Contact Us - Etc Settings - Footer
Then in your master page template, you would need to get a reference to the 'Footer' page, and pass this to the PartialFooter partial view, so this partial always worked with the Footer content.
eg
Your PartialFooter view should 'expect' an object of IPublishedContent
You could also save this partial executing on every page by using
@Html.CachedPartial("~/Views/Partials/PartialFooter.cshtml",footerContent,3600)
to cache the output for 3600 seconds...
My structure is like this at the moment
My footer document type contains 2 textboxs with alias locationAddress and cvrNumber.
My partial view looks like this.
My master view looks like i posted in the start of the thread
And then i also got a template called footer. I am not sure if it is redundent or not. It looks exactly like the partial footer view.
I hope this clerify how my program looks a bit better. And sorry for how messy it looks, and it is to read. :)
Marc Goodson, does your solution still works? and do you have any better idea of how to go about it..
In the end. My footer should contain CMS content and being able to get data from a different database than Umbracos.
Thank you @Marc Goodson! It worked!!
Glad you got it working Magnus!
is working on a reply...