Using Helper TinyMCE in cakePHP 1.2

Using tinyMCE in cakePHP already guide in previous lesson (http://blog.javamonday.com/2016/06/using-tinemce-ibrowser-with-cakephp.html). However, in this lesson, i am going to guide you how to using tinyMCE through a helper tinyMCE of cakePHP.



Setup tinyMCE
You can download newest tinyMCE at : http://tinymce.moxiecode.com/download.php and copy /tinymce/jscripts/tiny_mce folder to /app/webroot/js folder.

Create helper tinyMCE
You create a helper tinyMCE  with path : app/views/helpers/tinymce.php. You can get source at : http://blog.javamonday.com/2016/06/helper-tinymce.html.

Use in controller
You declare using helper tinyMCE in controller follows

var $helpers = Array('Form', 'Tinymce'); 
Use in view
Use tinyMCE helper in view will same as use helper forms, html in cakePHP. To declare a textarea using tinyMCE, you only add some code:

<?php echo $tinymce->input('content') ?>

Here are two sample code page to view your reference:
Paragraph 1

<div class="form-container">
  <?php echo $form->create('Page'); ?>
    <fieldset>
      <legend>Page</legend>
      <?php
        echo $form->input('title');
        echo $tinymce->input('content');
      ?>
    </fieldset>
  <?php echo $form->end('Save'); ?>
</div>
Paragraph 2: In here, we will config some options of tinyMCE

<div class="form-container">
  <?php echo $form->create('Page'); ?>
    <fieldset>
      <legend>Page</legend>
      <?php
        echo $form->input('title');
        echo $tinymce->input('content', null, array(
          'theme'                             => 'advanced',
          'theme_advanced_toolbar_location'   => 'top',
          'theme_advanced_toolbar_align'      => 'left',
          'theme_advanced_statusbar_location' => 'bottom',
        ));
      ?>
    </fieldset>
  <?php echo $form->end('Save'); ?>
</div>

The advantage of using helper tinyMCE is you can choose any textarea what use tinyMCE. We can config each textarea with our idea.