Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Typing variables in the cms editor


Go to End


3 Posts   2344 Views

Avatar
heidgert

Community Member, 16 Posts

28 July 2009 at 5:17am

Edited: 28/07/2009 5:19am

Is there any way to allow an editor to type a variable name into the TinyMCE editor content field and have Silverstripe parsing it from a function in my page controller?

For example:

* I have a function called VersionNumber in my Page_Controller class which fetches a products name and version number from some location and returns it. I also have a function named ReleaseDate which (yes) fetches and returns the ReleaseDate.

* An editor types "The most recent release is $VersionNumber which was released $ReleaseDate".

I want editors to be able to use the $VersionNumber and $ReleaseDate throughout the entire site so avoid manually updating something like this on several locations.

Is this possible? I've tried a few different things but haven't managed (the string $VersionNumber is written out in plain text).

Avatar
Howard

Community Member, 215 Posts

28 July 2009 at 3:13pm

Avatar
heidgert

Community Member, 16 Posts

10 August 2009 at 1:04am

Yay! Works like a charm. I've been searching for this without realizing there was a recipe about this.

Thanks!