blog.calebnance.com

It's So Loud, Inside My Head...

Friday, 30 December 2011 10:37

How To Add A Content Editor In Your Component

Written by  Caleb Nance

Today I wanted to show you how easy it is to add a content editor in your Joomla component form.

First we want to get the editor, so I usually put this line of code at the top of my form.php file.

$editor = JFactory::getEditor();

Then we go to where you want the content editor to be in your form and place this line of code:

<?php echo $editor->display('content', $this->content, '450', '200', '60', '20', false); ?>

The above parameters are FIELD NAME, FIELD VALUE, HEIGHT, WIDTH.

Now once we hit save in the component, we want the content to stay in it's HTML form, so we go to the Save function, usually in your controller, and after the $post we want to place this line:

$post['content'] = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW);

And that is it! Make sure what ever you have your content field in the database as, you change the content above with that field name. Cheers!

Last modified on Friday, 30 December 2011 10:53
blog comments powered by Disqus