Personal tools
You are here: Home Symfony Add TinyMCE to a Symfony project
Document Actions
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Add TinyMCE to a Symfony project

by Pierre-Yves Landuré last modified 2010-03-13 16:03

TinyMCE is a inline Wysiwyg HTML editor that is very well integrated with Symfony. Still, you need to download third party sources if you want to use it. This article help you through this process.

Note : This article need you to install the unzip tool. For Debian and Ubuntu, you can install it with apt-get :

/usr/bin/sudo /usr/bin/apt-get install unzip

Installing TinyMCE

First, configure the emplacement of the root of you Symfony project :

PROJECT_HOME=/home/sfprojects/myProject

Choose also the application you want to use TinyMCE with :

PROJECT_APP=frontend

Configure the TinyMCE version you want to use :

TINYMCE_VERSION=3.0.5

We remove the dots from the TinyMCE version :

TINYMCE_CLEANED_VERSION=`echo $TINYMCE_VERSION | sed -e 's/\./_/g'`

We download TinyMCE sources :

/usr/bin/wget http://ovh.dl.sourceforge.net/sourceforge/tinymce/tinymce_$TINYMCE_CLEANED_VERSION.zip \
--output-document=/tmp/tinymce_$TINYMCE_VERSION.zip

We unzip the downloaded file :

/usr/bin/unzip -o /tmp/tinymce_$TINYMCE_VERSION.zip -d /tmp

If you want, you can also download translations for TinyMCE :

/usr/bin/wget http://services.moxiecode.com/i18n/download.aspx?format=zip\&product=tinymce \
--output-document=/tmp/tinymce_language_pack.zip

Unzip the downloaded file in the target directory :

/usr/bin/unzip -o /tmp/tinymce_language_pack.zip -d /tmp/jscripts/tiny_mce

And move the TinyMCE source folder to the target emplacement in your Symfony project :

/bin/cp -r /tmp/jscripts/tiny_mce/ "$PROJECT_HOME/web/js/"

Now, configure your Symfony project to use TinyMCE :

/bin/sed -i -e '/^  .settings:/a\
rich_text_js_dir: js/tiny_mce' "$PROJECT_HOME/apps/$PROJECT_APP/config/settings.yml"

Warning: Check your settings.yml file to make sure that everything want well :

/usr/bin/vim "$PROJECT_HOME/apps/$PROJECT_APP/config/settings.yml"

You can now remove the downloaded files :

/bin/rm -r /tmp/tinymce
/bin/rm /tmp/tinymce_language_pack.zip
/bin/rm /tmp/tinymce_$TINYMCE_VERSION.zip

You can now use TinyMCE with PHP codes like :

<?php echo textarea_tag('name', 'default content', 'rich=true size=10x20') ?>
<?php echo textarea_tag('name', 'default content', array(
'rich' => true,
'size' => '10x20',
'tinymce_options' => 'language:"fr",theme_advanced_buttons2:"separator"',
)) ?>

Thanks

Very useful...

Posted by Blaise at 2008-04-16 17:42
Thanks for sharing this! It works perfectly!

Ridiculously easy...

Posted by Mauro at 2008-05-05 16:19
Great job Pierre.
I've blindly followed your steps and it worked like a charm.

Thank you so much!!

In Thanks section...

Posted by Nicolas Dubois <ndubois@waterproof.fr> at 2008-05-07 16:37
... you definitely have to thank yourself for this awesome script!

admin genarator - formatting not getting saved

Posted by Naga Gangadhar Reddy at 2008-11-24 16:23
used the same way....able to see the tinymce but.......formatting is not getting saved...used object_textarea_tag rather textarea_tag

TinyMCE in ajax form

Posted by Pierre-Yves Landuré at 2008-11-25 09:21
You are probably using TinyMCE in a ajax saved form. I've a page in french that has the solution to this problem:

http://howto.landure.fr/symfony/trucs-et-astuces-symfony

You can try to translate it using google,or search the web for tinymce, symfony and ajax.

Thank you very much.

Posted by zhuozi at 2009-01-08 08:14
Thank you for your help.

It might be simpler

Posted by André Lademann at 2009-03-04 21:42
Hi!
It might be simpler to use the debian package "tinymce" mit "apt-get install tinymce".
Mybe its not the newest, but it still works!

problem

Posted by ami at 2009-12-22 04:56
i have some problem in use tiny MCE

result like this
" <p>dasar- dasar drupal</p> <p>hal - hal yang harus diperhatikan</p> "

but i not want html script view

do u have solution??


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards:

Wikio