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:
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)
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?
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
is working on a reply...