Professional CodeIgniter

(singke) #1

Chapter 8: Last-Minute Upgrades


259


Integrating the TinyMCE Editor


If you ’ ve been paying attention, you ’ ll notice that the text area isn ’ t WYSIWYG. That ’ s because you
haven ’ t added the necessary code to make that happen! Remember what you did before, in the pages
area? You added a small bit of code to the controller ’ s constructor, then echoed the appropriate piece on
the view.

Therefore, in your Subscribers controller, add this bit to the constructor function:

function Subscribers(){
parent::Controller();

if ($this- > session- > userdata(‘userid’) < 1){
redirect(‘welcome/verify’,’refresh’);
}

$this- > tinyMce = ‘
< !-- TinyMCE -- >
< script type=”text/javascript” src=”’. base_url()
.’js/tiny_mce/tiny_mce.js” > < /script >
< script type=”text/javascript” >
tinyMCE.init({
// General options
mode : “textareas”,
theme : “simple”
});
< /script >
< !-- /TinyMCE -- >
’;
}

Next, add the following line to the top of the admin_subs_email view:

echo $this- > tinyMce;

The result should look something like Figure 8 - 9.
Free download pdf