Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, we have some values that we don't want to be hard-coded in Umbraco. What would be the best approach to let user insert pre-definied "variables" in editor and then render those variables ?
For exemple i would like to let my users create content such as :
"You have until $$LIMIT_DATE$$ to send us bla bla bla..."
And then have some code to replace variables ($$xyz$$) with values coming from a DB.
I think I would use a helper in the view. Something like:
In that helper you can look for your special characters and replace it with a value. The only problem with this solution is that you need to access the database every pageload.
To prevent that I would store the values in a settingsnode. Than it is cached and available as a Model so you can do something like:
A very basic implementation would be something like:
var richText = Model.Content.GetPropertyValue<IHtmlString>("content"); // or from model if you use model builder
var replaced = new HtmlString(richText.ToString().Replace("$$LIMIT_DATE$$", replacementValue));
Thanks Frans and Dan, two great ideas.
I was looking for something more generic : a solution that would apply to all views maybe.
Can you elaborate more on what you are trying to do? The solutions above are usable in every view.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted