views:

442

answers:

5

hi all

i need to use Tinymce in my project on zend framework, but i dont know how to use of it ! anyone may help and give an example?

thanks

+2  A: 

There are plenty of examples on the TinyMCE website. For easy implementation with Zend Framework and your templates you could write a View Helper.

Htbaa
+1  A: 

There is some discussion and an implementation here

Shane O'Grady
A: 

Well, upload the library somewhere to your public folder then in controller action do:

$this->view->headScript()->appendFile('/some/path/tiny_mce.js');
$this->view->headScript()->appendFile('/some/path/tiny_mce-init.js');

Where tiny_mce-init.js file could look something like this:

tinyMCE.init({
        theme : "advanced",
        mode : "textareas",
        // styles of the WYSIWYG content
        content_css : "/css/tiny_mce.css",
});

That will turn all textareas to WYSIWYG editors.

Richard Knop
That would make sense but for some reason when i tried this previously it seemed to wrap the editor around the wrong element
seengee
A: 

In the following code I created a Decorator I can use with textareas to show the WMD editor (the one used here). https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/decorator/Wmd.php

And in this code I simply extended the Text-area to automaticly use the decorator from above. https://phpancake.svn.sourceforge.net/svnroot/phpancake/library/lib/form/element/WmdTextArea.php

You can take that and replace with the mark-up of tinymce.
and in the code:

$Form=new Zend_Form(....);
$Form->addElement(new lib_form_element_WmdTextArea('my_name'...other text area params);
Itay Moav
A: 

Very similar to Richard Knop's answer i know but i found that it would only work like this for some reason, otherwise the editor was always wrapped round the wrong element:

$this->view->headScript()->appendFile("/scripts/vendor/tiny_mce/tiny_mce.js","text/javascript")
                         ->appendFile("/scripts/addtinymce.js","text/javascript");

and in addtinymce.js:

tinyMCE.init({
    mode : "exact",
    elements : "yourcontent",
    theme : "simple"
});
seengee
now , how do i make view helper??? if its possible give a complete example
ulduz114