Integrate tinyMCE into Yii - not working yet

Hi,

I started playing with WYSIWG Editors lately.

I tried the TinyMCE extensions, however it still contains the old version of tinyMCE + its has a few bugs.

Now I want to integrate the native TinyMCE files you can download from the website directly:

However it still doesn’t work.

Here is what I did so far:

  1. Downlaod tinyMce here: http://tinymce.moxiecode.com/download/download.php (jquery package)

  2. save it in my "js/" Folder

  3. include the following Code in my viewfile:







<?php

	Yii::app()->clientScript->registerCoreScript('jquery');

	Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/tinymce/jscripts/tiny_mce/jquery.tinymce.js", CClientScript::POS_HEAD);




	$script = 	'	$("textarea").tinymce({

					script_url: "/js/tinymce/jscripts/tiny_mce/tinymce.js",

					language: "en",

					theme: "advanced",

					theme_advanced_toolbar_location: "top",

					theme_advanced_toolabr_align: "left",

					theme_advanced_source_editor_width: "500",

					theme_advanced_source_editor_height: "400",

					theme_advanced_statusbar_location: "bottom",

					theme_advanced_resizing: true,

					theme_advanced_resize_horizontal: false,

	

					

				});

			';


	Yii::app()->clientScript->registerScript(

		'myScr',

		$script, 

		CClientScript::POS_READY);







?>





<?php echo $form->labelEx($model,'meal Speisekarte'); ?>

<?php echo $form->textArea($model,'mealDescription',array('rows'=>20, 'cols'=>50)); ?>

<?php echo $form->error($model,'mealDescription'); ?>



Can anybody help?!

THX

I found the error.




script_url: "/js/tinymce/jscripts/tiny_mce/tinymce.js",



First, The file name is tiny_mce.js

Second, Its recommended to add Yii::app()->baseUrl:




"'.Yii::app()->baseUrl.'/js/tinymce/jscripts/tiny_mce/tiny_mce.js",



This one is tested with tinymce_3.4.3.1 Jquery build.

Btw for further javascripts use Chrome Inspector or Firebug to see where the js errors are (i found the error this way)

THX,

however I still get the following error:


 

$("textarea").tinymce is not a function

theme_advanced_resize_horizontal: false, 



Could you please post your view-file

I copied what you wrote here:




<?php $this->pageTitle=Yii::app()->name; ?>


<?php

        Yii::app()->clientScript->registerCoreScript('jquery');

        Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/js/tinymce/jscripts/tiny_mce/jquery.tinymce.js", CClientScript::POS_HEAD);




        $script =       '       $("textarea").tinymce({

                                        script_url: "'.Yii::app()->baseUrl.'/js/tinymce/jscripts/tiny_mce/tiny_mce.js",

                                        language: "en",

                                        theme: "advanced",

                                        theme_advanced_toolbar_location: "top",

                                        theme_advanced_toolabr_align: "left",

                                        theme_advanced_source_editor_width: "500",

                                        theme_advanced_source_editor_height: "400",

                                        theme_advanced_statusbar_location: "bottom",

                                        theme_advanced_resizing: true,

                                        theme_advanced_resize_horizontal: false,

        

                                        

                                });

                        ';


        Yii::app()->clientScript->registerScript(

                'myScr',

                $script, 

                CClientScript::POS_READY);







?>




<form>

<label>Meal Description</label><br>

<textarea name="mealDescription" rows="20" cols="50"></textarea>

</form>



Where is your “js” folder? Are you sure you didn’t put it under the “protected”? It should be under the root of you project. In my case its:

/var/www/yiitest/js/ (i am using linux)

I use this bundle (CKEditor+Image Browser/Uploader)

http://www.yiiframework.com/extension/ckkceditor