CakeDCの TinyMCE Plugin を使ってみた。
TinyMCE の本家です。プラグインの中に入ってるので特に今回は必要なし。
http://tinymce.moxiecode.com/
CakePHPのTinyMCEプラグインはここからダウンロード。
http://cakedc.com/eng/downloads/view/tinymce
tests_controller.php
var $helpers = array('TinyMce.TinyMce');
/views/tests/add.ctp
<?php echo $this->TinyMce->editor(array( 'language' => 'ja', 'mode' => 'textareas', 'theme' => 'advanced', 'plugins' => 'spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template', 'theme_advanced_buttons1' => 'save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect', 'theme_advanced_buttons2' => 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor', 'theme_advanced_buttons3' => 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen', 'theme_advanced_buttons4' => 'insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage', 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' > 'true', 'skin' => 'o2k7', 'skin_variant' => 'silver', 'template_external_list_url' => '/tiny_mce/js/tiny_mce/template_list.js', 'external_link_list_url' => '/tiny_mce/js/tiny_mce/link_list.js', 'external_image_list_url' => '/js/tiny_mce/image_list.js', 'media_external_list_url' => '/tiny_mce/js/tiny_mce/media_list.js', )); ?> <div class="tests form"> <?php echo $this->Form->create('Tests');?> <fieldset> <legend><?php __('Add Tests'); ?></legend> <?php echo $this->Form->input('body'); ?> </fieldset> <?php echo $this->Form->end(__('Submit', true));?> </div> <div class="actions"> <h3><?php __('Actions'); ?></h3> <ul> <li><?php echo $this->Html->link(__('List Tests', true), array('action' => 'index'));?></li> </ul> </div>
TinyMce の設定をあらかじめ何種類か書いておくことが出来るみたいなのですが、
プラグイン自体に書き込む方法しかわからなかった。
controller から入れることは出来る気がするんですが…。
テキストエリアは自動で WYSIWYG で編集できるようになります。
ちなみに、TinyMCEのファイルや画像のアップロードを行なうプラグインは有料なので注意。