Xataface CKeditor Module 0.3
CKeditor Widget for Xataface
|
The Schema Browser plugin adds a button to the CKeditor toolbar that opens a palette to select a field from a particular table. This depends on the Schema Browser javascript component included with Xataface 2.0 (SVN rev 3126 or higher).
Dataface_JavascriptTool
::getInstance()
->import('xataface/modules/ckeditor/plugins/SchemaBrowser.js');
widget:ckeditor:toolbar="XBasic" widget:ckeditor:extraPlugins="SchemaBrowser"
If the schema browser plugin is successfully enabled for a particular CKeditor instance you will see an "add field" icon on the editor's toolbar.
Clicking on this will pop up a palette with a tree showing the fields that are available in the current table.
To add a field to the HTML editor document, simply click on a field in the schemabrowser. This will add a text macro to the document in the form:
{$fieldname}
or
{$relationshipname.fieldname}
for related fields.
The intention is that you can parse this information out however you like.
By default the schema browser will only show fields in the current table. If you want to change this so that it uses a different table, simply add the data-xf-schemabrowser-tablename
HTML attribute to the textarea on which the CKeditor is installed. You can either do this dynamically or via the widget:atts:data-xf-schemabrowser-tablename
directive in the fields.ini file.
The following example comes from templates feature of the Email module. When designing an email template, the user can select which table the template should act on from a select list. In this case it listens for changes to this select list and sets the data-xf-schemabrowser-tablename
attribute accordingly:
$('#table_name').change(function(){ CKEDITOR .instances .email_body .element .setAttribute( 'data-xf-schemabrowser-tablename' , $(this).val() ); });