If you want to reuse a part of a page, say a footer, that you create on the homepage of your site, you could reference the "homepae" from any page you have, and then render the "footer" of the "homepage".
Something like this :
@{
var homepage = Model.Content.AncestorOfSelf("homepage");
if(homepage != null)
{
// partial view, that renders the footer...
Html.RenderPartial("Footer", homepage);
}
}
Reusable / shared blocks, built-in functionality in Umbraco? (v8.6.4)
Is there built-in functionality for reusable / shared blocks (ie: using the same block on multiple pages) in Umbraco version 8.6.4?
Or is this only achievable through plugins / custom code?
Thanks in advance!
Hi Stefan
If you create content without a template, the content will not be able to be routed (no url), thus creating a "shared block". https://our.umbraco.com/documentation/tutorials/creating-basic-site/document-types/
To render the "shared block", you can just render it using a partial view https://our.umbraco.com/Documentation/Reference/Templating/Mvc/partial-views
HTH :)
Not quite what I was looking for.. The block templates are already created.
What I'd like to achieve is the possibility to create a block with content which can then be referenced on multiple pages.
In umbraco you have to put the content somewhere in the content tree. Creating node without a template, is a way for the content to not get an url.
A similar solution has been discussed here https://our.umbraco.com/forum/using-umbraco-and-getting-started/92091-reusable-content and here https://our.umbraco.com/forum/using-umbraco-and-getting-started/104665-how-to-do-reusable-content-global-content-for-content-editors
I would just suggest not using a macro, and use a content picker and a partial view instead.
You would need to share the templates (or copy the content) every place you display the shared content.
If you want to reuse a part of a page, say a footer, that you create on the homepage of your site, you could reference the "homepae" from any page you have, and then render the "footer" of the "homepage".
Something like this :
is working on a reply...