CodeIgniter Forums

Full Version: tinyMca with CI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dunken[/eluser]
Hi everybody! (Hi, dr Nick).

I am about (for the first time) to implement the tinyMCE application (javascript) to a CI-project...and I realy dont know how to do.

Is the easiest way to do this by making av new model with a echo statement saying "include this, include that"

class Tinymce{
function Tinymce(){

}

index(){
echo 'my different .js-files';
}
}

and after this, just call my tinymca-class every time I need to use it?

El Forum

[eluser]bobbob[/eluser]
did you mean timyMCE?
It works very easily with CI

El Forum

[eluser]dunken[/eluser]
i mean tinyMce (sorry for my misspelling). ( http://tinymce.moxiecode.com/ )

shall i proceed as my plan or in some other way?

El Forum

[eluser]bobbob[/eluser]
Add the tiny mce code in your controller and header view as below and then drop the tinymce folder into your js folder in the root of your site.

root
css
images
index.php
js


Also note the xss_clean feature of this forum removed the script tags.

Controller:

Code:
$extrahead = '[removed]script type="text/javascript" src="js/tiny_mce/tiny_mce.js[removed]
        [removed]
tinyMCE.init({
    // General options
    mode : "textareas",
    theme : "advanced",
    plugins : "safari,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,imagemanager,filemanager",

    // Theme options
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,forecolor,backcolor",
    
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : false,

    // Example content CSS (should be your site CSS)
    content_css : "styles.css",

    // Drop lists for link/image/media/template dialogs
    template_external_list_url : "js/template_list.js",
    external_link_list_url : "js/link_list.js",
    external_image_list_url : "js/image_list.js",
    media_external_list_url : "js/media_list.js"

    
    
});
[removed]';
            $data['extrahead'] = $extrahead;
            $data['header'] = $this->load->view('header',$data);

HEADER VIEW:
Code:
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><?php echo $title; ?></title>
<base href="<?php echo base_url(); ?>">


<?php if(isset($extrahead)) {
echo $extrahead;
}
?>

</head>

El Forum

[eluser]brianw1975[/eluser]
er.... you nearly *always* avoid any form of echo, sprintf, etc from a Model.

A more MVC method would be to do something along the lines of (in your controller)

Code:
class cont exte.......... er{
function .......(){
  if($I_need_to_show_tinymce === true){
     $data['showTinyMCE'] = true;
  }
  $this->load->view("my_view_file.file",$data);

and then in your view file have:
Code:
<?php if($data['showTinyMCE'] === true) ?>
[removed]......... js stuff in here....[removed]
<?php endif ?>

Like I said, prescribed MVC methodologies put down using models to affect views, but only to give and take data for the controllers.