# DDEditor Yii Extension This extension contains a widget to render an activeTextarea to enter Markdown text. The rendered widget contains some buttons to add markdown tags for * Bold, italic text * Links * Images * Code * Table structure. It is also capable of displaying dropdown lists with _additional text snippets_ for insertion. ### Requirements * Yii 1.1.3 or above ### Installation * Extract the release file under `protected/extensions` ### Usage #### Include New Extension In your `config/main.php` file, add // autoloading model and component classes 'import'=>array( ... 'application.extensions.ddeditor.*', ... ), #### Create the controll in a form view: In e.g. `views/post/_form.php`, include the following code: widget( 'application.extensions.ddeditor.DDEditor', array( 'model'=>$model, 'attribute'=>'content', 'htmlOptions'=>array('rows'=>10, 'cols'=>70), 'previewRequest'=>'post/preview')); ?> If you want to display an **extra dropdown list** with **snippets**, you may add the _additionalSnippets_ parameter: array( 'id1' => 'John', 'id2' => 'Paul', ), 'Phrases' => array( 'Text Foo' => 'foo', 'Text Bar' => 'bar' ) ); ?> widget( 'application.extensions.ddeditor.DDEditor', array( 'model'=>$model, 'attribute'=>'content', 'htmlOptions'=>array('rows'=>10, 'cols'=>70), 'previewRequest'=>'post/preview', 'additionalSnippets'=>array('My Snippets'=>$mySnippets), ); ?> #### Add a Controller Preview Action In order to receive a rendered preview of the textarea Markdown, add an action method to a controller: public function actionPreview() { $parser=new CMarkdownParser; echo $parser->safeTransform($_POST['Post'][$_GET['attribute']]); } ### Resources * [Demo](http://www.diggin-data.de/ddeditor) * [Discussion](http://www.yiiframework.com/forum/index.php?/topic/11384-new-extension-markdown-editor) ### Changes #### March 29, 2010 * **V0.4** * Added code sample for using _additionalSnippets_ in README * Added reset of _additional snippets_ dropdown list after selection #### March 28, 2010 * **V0.3** * Fixed _Depreciated: split_ warning * Added _additionalSnippets_ member * Added _Code Highlighter_ dropdown list #### August 31, 2010 * **V0.2** * Fixed setting `$previewReaquest` * Fixed setting client script id's for using multiple editors in one form #### August 30, 2010 * **V0.1** Initial release.