In one of my joomla custom form, I am rendering an editor as follows
<?php
$qu=$question ? $question : '';
$editor = JFactory::getEditor();
echo $editor->display('question', $qu, '100%', '400', '80', '15');
?>
The editor was working fine But when I am trying to submit after formatting, its html part won't get sumitted. If the editor was loading from xml filter="safehtml" or filter="raw" will work. But how to enable html in this case ?
Please help
Thanks in advance
The problem lies in JRequest::GET which by default strips all html.
You have to ask specifically the input you want html from.
JRequest::getVar( 'yourfieldname', '', 'post', 'string', JREQUEST_ALLOWHTML );
Joomla Docs
Related
I know there are some code to get the editor in joomla itself like
<?php
$editor = JFactory::getEditor();
echo $editor->display('description', $row->description, '550', '400', '60', '20', false);
?>
But after i submit the form, the content will go back to plain text.
I must miss out something, hope someone could help me.
Try below code at action page to get value. Hope it helps.
$description = JRequest::getVar('description', 'default value goes here', 'post','validation type',JREQUEST_ALLOWHTML);
I want to keep the text which has been styled for sometime in Ckeditor even if there is an error in form_validation and the browser redirects to the previous page that you have been working on.
Of course, I've used set_value() in my input options, but the problem still remains.
this is the code in my view file:
<? $news_Body = array('name' => 'news_Body', 'value' => set_value('news_Body'), 'tabindex' => '16'); echo form_textarea($news_Body)?>
<?php echo display_ckeditor($ckeditor); ?>
All of the other inputs which set_value() has been used in them keep their value except the text_area with Ckeditor!
Have you added a validation for news_Body ? If not, set_value will not work.;
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
Is there someone who use CKEditor 4.0 in Codeigniter 2 project? I could find just inbtegrating with CKeditor 3. Very good tutorial, but project structure of forth version is differ from third. Pls, help to integrate ckeditor 4 with codeigniter 2 or pls share some link to tutorial with good explanation.
UPD
I tried this way. I added the following to my view
<script type="text/javascript">
CKEDITOR.replace( 'anons_area' );
</script>
<?php $anons_data = array(
'name' => 'anons',
'id' => 'anons_area',
'value' => 'Введите анонс',
'rows' => '10',
'cols' => '50',
'style' => 'width:50%',
);
echo form_textarea($anons_data); ?>
but it doesn't work.
UPD2
I found out why editor can't be loaded to browser. Firebug says that access forbiden to ckeditor.js script, You don't have permission to access the requested object.
It is either read-protected or not readable by the server.
Okay this really isn't hard at all...
Put this in the head of the page you want the ckEditor in, obviously pointing to the correct path for your application:
<script src="'.base_url().'assets/lib/ckeditor/ckeditor.js"></script>
Then in the body where you want the editor:
<textarea cols="80" id="editorName" name="editorName" rows="60">
</textarea>
At the bottom of the page:
<script type="text/javascript">
CKEDITOR.replace( 'editorName' );
</script>
It's honestly that easy.
using codeigniter & Ckeditor 4.02 based on code from the ck example page
<script src="<?php echo base_url();?>ckeditor/ckeditor.js"></script>
<?php
// static example to populate form with text
$formvalue = "Here is some text to appear in the form box. " ;
?>
<textarea class="ckeditor" name="editor1"><?php echo $formvalue ?></textarea>
You can also use the CI form helper
<?php
$formvalue = "Here is some text to appear in the form box." ;
$formdata = array(
'class' => 'ckeditor',
'name' => 'editor1',
'id' => 'SomeID',
'value' => $formvalue
);
echo form_textarea($formdata) ;
?>
Next step would be replacing $formvalue with a database result to populate the form (like editing a blog post, etc).
And if you use the CI Form helper it needs to be loaded first, the easiest is to autoload it in config/autoload.php
Now -- If some brilliant person has some tips on creating a custom tool bar...?
I've been battling this all morning and can't seem to find anything on how this works. I need the editor (system default) to show up in my back-end component.
My default editor is TinyMCE
I'm on Joomla 2.5.x
This is how far I've gotten with searching this forum and google.
Sample of my script
jimport( 'joomla.html.editor' );
$editor =& JEditor::getInstance();
echo $editor->display("desc", $itemData['body'], "600", "400", "80", "15", 1, null, null, null, array('mode' => 'advanced'));
All I'm getting is a HTML textarea with my content from the $itemData['body']. No editor. What am I missing?
THIS IS NOW SOLVED.
I did some more research and learned to use Joomla's JForm to create nice forms and have more control in my component in the back end.
jimport( 'joomla.html.editor' );
$editor = &JFactory::getEditor();
echo $editor->display('editorname', $this->detail->namechamp, '100%', '300', '75', '20');
We are building joomla component. And we use joomla editor in which we insert content.
But there is a problem, because when we add image to editor and save it, it do not add image to database and when we opening this element to edit it again, there is only text in editor, image disappears.
This is how we use it:
$editor =& JFactory::getEditor();
echo $editor->display('text', $this->hello->text, '800', '300', '20', '20');
Maybe there is need to supply aditional parameters to display method?
Problem solved.
The standard way of getting the form data $post = JRequest::get('post'); is not enough in the case of using a editor. This will filter the content, hence losing line breaks and paragraps. So we need to add an extra line to get the editor contents in a raw unfiltered way. This data will be passed to the model to save into the database.
To get HTML form post data you need to get this data in following way
$data = JRequest::getVar( 'editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW );
And need to add a javascript for the view(tmpl file)
function submitbutton(action) {
var form = document.adminForm;
switch(action)
{
case 'save':case 'apply':
<?php
$editor =& JFactory::getEditor();
echo $editor->save( 'editorName' );
?>
case 'publish':
case 'unpublish':
case 'cancel':
default:
submitform( action );
}
}