Joomla 1.5 Custom Parameter Type (WYSIWYG)

Posted by: gbluma

Tagged in: Programming , Joomla

joomlaJoomla has made module development a piece of cake. If you want a section of your module to display a poll or banner it's really easy. Likewise Joomla has made it easy to edit the content in those modules with module parameters.

... But one thing you haven't been able to do is edit those parameters in a WYSIWYG textarea... until now...

It's actually fairly simple. Copy the following and paste it into a new file at /joomla/libraries/joomla/html/parameter/element/editor.php

<?php
defined('JPATH_BASE') or die();

class JElementEditor extends JElement
{
	var $_name = 'editor';
	
	function fetchElement($name, $value, &$node, $control_name)
	{
		$value = str_replace('<br />', "\n", $value);
		$editor =& JFactory::getEditor();
		return $editor->display( $control_name.'['.$name.']', 
			$value, '80%', '400', '40', '15', null ) ;
	}
}

What this does is create a new "type" of parameter element called "editor." So we can now use it as another parameter in our xml files (as follows):

...
<params>
<param name="description" type="editor" default="hello" label="Description" description="Custom control" />
</params>
... 

It's not exactly pretty, but very functional. Let me know if this works for you.