Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ssougnez 46 posts 189 karma points c-trib
    May 18, 2018 @ 07:06
    ssougnez
    0

    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.

  • Frans de Jong 370 posts 1252 karma points c-trib
    May 18, 2018 @ 07:39
    Frans de Jong
    0

    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.

  • ssougnez 46 posts 189 karma points c-trib
    May 18, 2018 @ 09:53
    ssougnez
    0

    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.

  • ssougnez 46 posts 189 karma points c-trib
    Jul 06, 2018 @ 17:47
    ssougnez
    100

    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:

    @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.

  • Frans de Jong 370 posts 1252 karma points c-trib
    Jul 06, 2018 @ 17:51
    Frans de Jong
    0

    That's what I suggested ;-) Glad you found the solution.

  • ssougnez 46 posts 189 karma points c-trib
    Jul 06, 2018 @ 20:06
    ssougnez
    0

    Yes but at that time I didn’t really understood your answer hehe.

    Thanks anyway

Please Sign in or register to post replies

Write your reply to:

Draft