问题
I have created a custom field in Joomla 1.5 menu for description of the menu. I have edited the component.xml in administrator\components\com_menus\models\metadata
but now I want to put a text editor in place of a normal text-box. Any ideas how to approach this?
回答1:
You need to create an element of editor type.
Learn how to create element and how to save data
class JElementMyeditor extends JElement
{
var $_name = 'Myeditor';
/**
* @param $name
* @param $value
* @param $node
* @param $control_name
*/
function fetchElement($name, $value, &$node, $control_name)
{
$editor = JFactory::getEditor();
$width = $node->attributes('width');
$height = $node->attributes('height');
$col = $node->attributes('col');
$row = $node->attributes('row');
// ($name, $html, $width, $height, $col, $row, $buttons = true, $params = array())
return $editor->display($control_name.'['.$name.']',
htmlspecialchars($value, ENT_QUOTES),
$width, $height, $col, $row,
array('pagebreak', 'readmore') ) ;
}
}
And you can use this in xml as
<param name="custom_param"
width="300"
height="150"
type="myeditor"
label="LABEL"
description="DESC"
/>
来源:https://stackoverflow.com/questions/8895052/text-editor-for-custom-field-in-joomla