Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Jul 07, 2015 @ 10:42
    René Andersen
    0

    Linebreaks when using Macro "textarea" type

    Hi everybody

    Is it possible to make linebreaks when using the "textarea" type in macros?

    I have tried with <br> and pressing enter, but it seems to just override it and renders out the text without linebreaks.

    // René

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 07, 2015 @ 10:54
    Dennis Aaen
    0

    Hi René

    When you say textarea in a macro did you then mean the multiple textbook.

    If so the you can output the content of the field containing HTML like this

    @Html.Raw(CurrentPage.PropertyAlias)
    

    And I think remember to write the linebreaks like

    Hope this helps.

    /Dennis

  • René Andersen 238 posts 684 karma points
    Jul 07, 2015 @ 11:10
    René Andersen
    0

    Hi Dennis

    There is no "Multiple Textbox" in the macro parameters, I can only choose "textbox or textarea".

    This is the macro code where there should be linebreaks in:

    @Model.MacroParameters["text"]
    

    Is it possible to use "Html.Raw" with my code?

    // René

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 07, 2015 @ 11:48
    Dennis Aaen
    0

    Hi René

    Yes you can use the @Html.Raw in the macroParameters.

    I have made a code snippet for you.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{ var macroText = Model.MacroParameters["text"]; }
    @if (macroText != null)
    {
        @Html.Raw(macroText)
    }
    

    Hope this helps,

    /Dennis

  • René Andersen 238 posts 684 karma points
    Jul 08, 2015 @ 13:12
    René Andersen
    0

    Hi Dennis

    Your solution works perfectly in the Richtext editor but not with Grids.

    Do you have any idea why?

    // René

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Jul 08, 2015 @ 20:18
    Dennis Aaen
    1

    Hi René,

    I am not sure that this is possible in the Grid layout, so perhaps you should make a feature request about this http://issues.umbraco.org/issues/U4

    Maybe you could consider to make a normal field outside the grid layout using the data type multiple textbox.

    Then you can use this code.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @if (CurrentPage.HasValue("propertyAlias"))
    {
        @Html.Raw(CurrntPage.propertyAlias)
    }
    

    Or as you already know then you can use it with a macro parameter outside the grid layout.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{ var macroText = Model.MacroParameters["text"]; }
    @if (macroText != null)
    {
        @Html.Raw(macroText)
    }
    

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft