Page 1 of 1

Calling FCKEditor in a front end module

Posted: Thu Dec 22, 2005 12:59 pm
by katon
I am developing a Front End module, and I need FrontEnd users to be able to enter their data through a WYSIWYG editor.  I can call a regular textarea with CreateTextArea, but changing the $enablewysiwyg parameter from false to true doesn't change a thing.  Maybe there is another way of doing this? ???

Thank you in advance.

Re: Calling FCKEditor in a front end module

Posted: Sat Dec 24, 2005 1:55 pm
by katon
To do this, I have created and called the following method:

Code: Select all


	/**
	 * Returns the xhtml equivalent of a FCK wysiwyg editor.
	 *
	 * @param string The id given to the module on execution
	 * @param string The text to display in the textarea's content
	 * @param string The html name of the textarea
	 * @param string The CSS class to associate this textarea to
	 * @param string The html id to give to this textarea
	 * @param string The encoding to use for the content
	 * @param string The text of the stylesheet associated to this content.  Only used for certain WYSIWYGs
	 * @param string The number of characters wide (columns) the resulting textarea should be
	 * @param string The number of characters high (rows) the resulting textarea should be
	 */
    
    function create_fe_wysiwyg($mid, $text, $name, $classname='', $id='', $encoding='', $stylesheet='', $width='', $height='')
    {
	global $gCms;
	$result = '';

	$wysiwyg = $this->GetModuleInstance('FCKeditorX');
	if( $wysiwyg )
	{
	    $enablewysiwyg = true;
	}
	else
	{
	    $enablewysiwyg = false;
	}

	if ($enablewysiwyg == true)
	{
	    foreach($gCms->modules as $key=>$value)
	    {
		if ($gCms->modules[$key]['installed'] == true &&
		    $gCms->modules[$key]['active'] == true &&
		    $gCms->modules[$key]['object']->IsWYSIWYG())
		{
		    $result = '';
		    ob_start();
		    echo $gCms->modules[$key]['object']->WYSIWYGTextarea($mid.$name,$width,$height,$encoding,$text,$stylesheet);
		    $result = ob_get_contents();
		    ob_end_clean();
		}
	    }
	}

	if ($result == '')
	{
	    $result = '<textarea name="'.$name.'" cols="'.$width.'" rows="'.$height.'"';
	    if ($classname != '')
	    {
		$result .= ' class="'.$classname.'"';
	    }
	    if ($mid != '')
	    {
		$result .= ' id="'.$mid.'"';
	    }
	    $result .= '>'.cms_htmlentities($text,ENT_NOQUOTES,get_encoding($encoding)).'</textarea>';
	}

	return $result;
}


Re: Calling FCKEditor in a front end module

Posted: Mon Dec 26, 2005 1:54 am
by Ted
Glad you worked that out.  I didn't have a quick reply to give you when I originally read this.