I propose a plugin that is a much extended version of the placeholder plugin. It alows you to define the variables that are later replaced on the server, much like the "Insert Field" in MS Word. Features:
- content (text) of the variable can't be edited (this doesn't work for "placeholder" in FF)
- every variable has a type and additional properties depending on type (e.g. formatting options for currency, dates, display options for images...)
- different types of variables are displayed differently (images as an image placeholder, number as a number)
- available variables are supplied server side (maybe through a config file) along with their types and default properties, editor supports more than one such setup (e.g. first name, last name, email... for editor used to edit HTML mails; date edited, name of the editing user for a simple CMS page)
- styling of the variable should project on the value of the variable (bold, italic...)
I implemented such a system for 2.x but it required some fiddling with the core of the editor. Perhaps some of this things should be taken in consideration while implementing 3.0. What I was forced to change:
- some event handling that prevented changing of the variable contents or braking it into more pieces
- some smart dynamic inserting of blanks that allowed to add text before or after the variable (if variable was at the beginning of the document or at the end of the line)
- before submitting, transforming tags (i used spans) and attributes to a form used by a serverside templating engine (for this, editor had to be in design - not source - mode)
If this can be cleanly rewritten in 3.0, I could easily contribute it to the effort. Also, while doing this and some other tweaking I got to know the editor quite well and would be prepared to assist in the development...
- content (text) of the variable can't be edited (this doesn't work for "placeholder" in FF)
- every variable has a type and additional properties depending on type (e.g. formatting options for currency, dates, display options for images...)
- different types of variables are displayed differently (images as an image placeholder, number as a number)
- available variables are supplied server side (maybe through a config file) along with their types and default properties, editor supports more than one such setup (e.g. first name, last name, email... for editor used to edit HTML mails; date edited, name of the editing user for a simple CMS page)
- styling of the variable should project on the value of the variable (bold, italic...)
I implemented such a system for 2.x but it required some fiddling with the core of the editor. Perhaps some of this things should be taken in consideration while implementing 3.0. What I was forced to change:
- some event handling that prevented changing of the variable contents or braking it into more pieces
- some smart dynamic inserting of blanks that allowed to add text before or after the variable (if variable was at the beginning of the document or at the end of the line)
- before submitting, transforming tags (i used spans) and attributes to a form used by a serverside templating engine (for this, editor had to be in design - not source - mode)
If this can be cleanly rewritten in 3.0, I could easily contribute it to the effort. Also, while doing this and some other tweaking I got to know the editor quite well and would be prepared to assist in the development...
Re: Variables in editor content
For V3, there is not much to be done in the core to support it. Actually, the core should not bring the features to do that, but simply be flexible enough, making it possible to implement it through a plugin.
We are working on the dialog system, which would fit tho the needs of this plugin quite well. It is a bit early to talk about it though, as everything is still under construction. You should give it a try as soon as we go beta.
Frederico Knabben
CKEditor Project Lead and CKSource Owner
--
Follow us on: Twitter | Facebook | Google+ | LinkedIn
Re: Variables in editor content
I've been searching for this kind of plugin for a week now. I'm extremely interested in your contribution.
Could you please make it publicly available on a website? You would save my day.
thanks in advance.
Fred Bricon
Re: Variables in editor content
<$cmd[
// Run Some Server Functions Here
return Date()
]/>
<$MyVariable />
and In 2.x I use this simple config:
FCKConfig.ProtectedSource.Add( /(<\$[\s\S]*?\/>)/gi ) ;
Which works just fine... but there is no representation in the WYSIWYG that the tags exist... it would be nice to be able to have an icon in the gui that can have triggers for a context menu. The icon represents the hidden tag. Sounds simple enough... I think it would be a great addition.
Can't wait till 3.0!!! Whats the release schedule looking like?
Re: Variables in editor content
but I'm currently looking for a way to Insert Variables in the Editor Content
Does anyone know of any way to do this... with examples?
or If there are any existing plugins that do this?
Cheers
Re: Variables in editor content
.
Look at the source code of the pagebreak plugin to see how to write a simple fake object plugin.
Thanks,
Zanpakutō
Re: Variables in editor content
I don't suppose anyone knows of any plugins already made to do this. I'm sure there must be some.
(I don't have the time/skill to modify existing pluggins to implement this feature)