我创建了自己的zend表单元素 - App_Form_Element_Wysiwyg
<?php
class App_Form_Element_Wysiwyg extends Zend_Form_Element_Xhtml
{
/**
* Default form view helper to use for rendering
* @var string
*/
public $helper = 'wysiwyg';
}
然后我为wysiwyg创建帮手 - App_View_Helper_Wysiwyg
<?php
class App_View_Helper_Wysiwyg extends Zend_View_Helper_FormTextarea
{
public function wysiwyg($name, $value = null, $attribs = null)
{
// Here I want to include js and css for wysiwyg editor
...
$xhtml = '<textarea name="' . $this->view->escape($name) . '"'
. ' id="' . $this->view->escape($id) . '"'
. $disabled
. $this->_htmlAttribs($attribs) . '>'
. $this->view->escape($value) . '</textarea>';
return $xhtml;
}
}
如何为wysiwyg编辑器包含js和css文件?
答案 0 :(得分:4)
headScript()
帮助程序允许您在标题中添加或操作脚本标记。所以在你的助手中你可以做到:
$this->view->headScript()->appendFile('/path/to/file.js');
然后确保你的布局在head部分的某处调用帮助器:
<?=$this->headScript()?>
输出HTML。还有headStyle()
助手,它以类似的方式工作,可以用于你的CSS。
相关文档: