is this possible to have "reusable content" in Umbraco ? Basically, it would be some pieces of HTML that content manager could define then insert into their page via the RTE. And if they change the content of the reusable content, it changes on every page it is used.
Does the content manager needs control over the HTML or the content?
You could take a look at partial view macro's. They can be used in the richtext editor.
If you are using Grid layout you could use DocType grid editor. A great package.
Yeah, that's the thing. Content manager needs to be able to create such content, they don't have to ask us to create some for them to be able to use them.
Basically, I created a document type called "Reusable content" with just a " ReusableContentBody" property.
Then I created a macro with a content picker parameter and the view is the following:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using SFPD.Core.DocumentTypes;
@{
if (Model.MacroParameters["ReusableContentRef"] != null)
{
var item = Umbraco.TypedContent(Model.MacroParameters["ReusableContentRef"].ToString());
if (item.DocumentTypeAlias == ReusableContent.ModelTypeAlias)
{
var rc = item as ReusableContent;
<div>@rc.ReusableContentBody</div>
}
}
}
So I just retrieve a reference to the parameter value, I checked if the document type is correct, and if it is, I display the property and poof, I have reusable contents.
Reusable content
Hello,
is this possible to have "reusable content" in Umbraco ? Basically, it would be some pieces of HTML that content manager could define then insert into their page via the RTE. And if they change the content of the reusable content, it changes on every page it is used.
I saw that this functionality seems to be included in this package: https://our.umbraco.org/projects/starter-kits/umazel-starter-kit-responsive-bootstrap-theme/ but I don't want to use a whole starter kit just for one functionnality.
Does the content manager needs control over the HTML or the content? You could take a look at partial view macro's. They can be used in the richtext editor.
If you are using Grid layout you could use DocType grid editor. A great package.
Yeah, that's the thing. Content manager needs to be able to create such content, they don't have to ask us to create some for them to be able to use them.
Hop,
I'll answer my own question.
Basically, I created a document type called "Reusable content" with just a " ReusableContentBody" property. Then I created a macro with a content picker parameter and the view is the following:
So I just retrieve a reference to the parameter value, I checked if the document type is correct, and if it is, I display the property and poof, I have reusable contents.
That's what I suggested ;-) Glad you found the solution.
Yes but at that time I didn’t really understood your answer hehe.
Thanks anyway
is working on a reply...