FCKEditor Helper
1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 2021 22 23 24 2526 27 28 29 3031 32 33 | <?php /** * @author Jeremy (Jeremy@slack5.net) * @link http://www.slack5.com */require_once(str_replace('admin_application', 'admin', APPLICATION_DIRECTORY).'/js/fckeditor/fckeditor.php'); class Zend_View_Helper_Rte { function rte($name, $value = null, $attr = array()) { $baseUrl = str_replace('/index.php', '', Zend_Controller_Front::getInstance()->getBaseUrl()); $headLink = new Zend_View_Helper_HeadLink(); // include js & css for rte $headScript = new Zend_View_Helper_HeadScript(); $headScript->headScript()->appendFile($baseUrl.'/js/fckeditor/fckeditor.js'); $oFCKeditor = new FCKeditor($name) ; $oFCKeditor->BasePath = $baseUrl.'/js/fckeditor/'; $oFCKeditor->Config['SkinPath'] = $oFCKeditor->BasePath."editor/skins/office2003/"; $oFCKeditor->Height = '400'; if (key_exists('height', $attr)) { $oFCKeditor->Height = $attr['height']; } $oFCKeditor->Value = $value; return $oFCKeditor->Create(); } } ## Usage <?php $this->rte('description', 'my default value'); ?> |
Comments
First, download on FCKEditor the corresponding files (fckeditor.php, notably).
Then, put it in your view helpers directory. If you don't have one dedicated to custom code, then, just put that file in /library/Zend/View/Helper as "Rte.php".
Don't forget to change the require_once to follow your directory layout.
In that case, you'd probably want to change the name of the class so that it isn't using the "Zend" prefix, and then add your new prefix and its path to your view:
$view = Zend_View();
$view->addHelperPath('Path/To/Helpers', 'My_View_Helper_');
Then, assuming your view script is in the scope of that view object, you could use the view helper just like any of Zend's prepackaged helpers.
Greetings,
where can I download the needed files??
Thank you.
PS. Really great work. I feel thankfull.
You can download fckeditor from http://www.fckeditor.net/
copy & paste the code into your rte helper file.
You must login before commenting on a snippet. If you do not have an account, please register.
1 year ago
I was JUST about to write this and visited here on a hunch. Thank you!! :)