Outils personnels
Vous êtes ici : Accueil Symfony Intégrer TinyMCE à un projet Symfony
Actions sur le document
  • Send this page to somebody
  • Print this page
  • Add Bookmarklet

Add TinyMCE to a Symfony project

Par Pierre-Yves Landuré - Dernière modification 13/03/2010 17: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...

Posté par Blaise le 16/04/2008 18:42
Thanks for sharing this! It works perfectly!

Ridiculously easy...

Posté par Mauro le 05/05/2008 17:19
Great job Pierre.
I've blindly followed your steps and it worked like a charm.

Thank you so much!!

In Thanks section...

Posté par Nicolas Dubois <ndubois@waterproof.fr> le 07/05/2008 17:37
... you definitely have to thank yourself for this awesome script!

admin genarator - formatting not getting saved

Posté par Naga Gangadhar Reddy le 24/11/2008 17: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

Posté par Pierre-Yves Landuré le 25/11/2008 10: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.

Posté par zhuozi le 08/01/2009 09:14
Thank you for your help.

It might be simpler

Posté par André Lademann le 04/03/2009 22: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

Posté par ami le 22/12/2009 05: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??


Réalisé avec Plone

Ce site respecte les normes suivantes :

Wikio