Copied to clipboard

Flag this post as spam?

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


  • Jonas Eriksson 930 posts 1825 karma points
    Apr 05, 2014 @ 16:22
    Jonas Eriksson
    0

    Editor editable dynamic text - using Richtextbox ? Ideas needed.

    From time to time the need for editor editable dynamic texts in a richtexteditor comes up, for example:

    Hello {name}! You ordered {quantity} pieces. {if (payed)} thank you for your payment {end if}.

    Now - the clients are not very happy with syntax like that, and would prefer some GUI help. So, the idea I have now is to create macros for this. A macro "Field Value" asks for the field to add into the text, and another macro "Optional Value" asks for an expression and a value to add optionally into the text.

    Which would create a useful dynamic, but rather ugly looking richtextbox, something like:

    Hello 
    -----------
    Umbraco macro "field" "Name"
    -----------
    ! You ordered
    -----------
    Umbraco macro "fieldvalue" "Quantity"
    -----------
    pieces.

    -----------
    Umbraco macro "optionalValue" "Payed" "Thank you for your payment"
    -----------

    I wonder if anyone else have tried this approach or has better ideas for this problem?

  • Jonas Eriksson 930 posts 1825 karma points
    Apr 06, 2014 @ 04:55
    Jonas Eriksson
    0

    Small progress notes : I made a macro with parameter for "fieldname" and made a custom richtextbox with a little bit of css to make the macro html appear inline and with some coloring:

    Unfortunately - as the macro html is a div it's a a problem getting it inside a p tag inside the richtextbox.

    The macro for showing the value of a property (fieldname is the macro parameter)

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{var fieldName = Model.MacroParameters["fieldname"].ToString().Trim();}    
    @if(Request.RawUrl.Contains("GetMacroResultAsHtmlForEditor")){
    {@fieldName}
    } 
    @Model.Content.GetPropertyValue(fieldName)
    

    The macro formatting css

    .mce-content-body .umb-macro-holder{
        display:inline;
        border:1px dotted orange;
        padding:1px;
    
    }
    .umb-macro-holder span {
        background:orange;
        padding:2px;
    
Please Sign in or register to post replies

Write your reply to:

Draft