Tuesday, May 1, 2012

Re: cakePHP 2.1, ckeditor + ckfinder

Yes,

Keep ckeditor inside js directory.

You need to put the ckfinder inside the wwwroot directory.

Create an element, ckeditor.ctp
<?php
echo $this->Html->script('/ckfinder/ckfinder', false);

if(!isset($description)){
$description = '';
}

echo $this->Form->textarea($name , array('label' => false , 'id' =>
$id , 'value' => $description));//,'class'=>'ckeditor'?>

<script type="text/javascript">

//var siteurl = '<?php //echo FULL_BASE_URL;?>';
//<![CDATA[

// This call can be placed at any point after the
// <textarea>, or inside a <head><script> in a
// window.onload event handler.

// Replace the <textarea id="editor"> with an CKEditor
// instance, using default configurations.
CKEDITOR.replace( '<?php echo $id;?>',
{
filebrowserBrowseUrl : '<?php echo FULL_BASE_URL;?>/ckfinder/
ckfinder.html',
filebrowserImageBrowseUrl : '<?php echo FULL_BASE_URL;?>/
ckfinder/ckfinder.html?type=Images',
filebrowserFlashBrowseUrl : '<?php echo FULL_BASE_URL;?>/
ckfinder/ckfinder.html?type=Flash',
filebrowserUploadUrl : '<?php echo FULL_BASE_URL;?>/ckfinder/
core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : '<?php echo FULL_BASE_URL;?>/
ckfinder/core/connector/php/connector.php?
command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '<?php echo FULL_BASE_URL;?>/
ckfinder/core/connector/php/connector.php?
command=QuickUpload&type=Flash',
width: '<?php echo $width; ?>',
height: '<?php echo $height; ?>',
contentsCss:['/css/global.css', '/css/ie7.css', '/css/jquery-
ui-1.8.16.custom.css', '/css/slider.css', '/css/bootstrap.css', '/css/
ie.css'],
enterMode: CKEDITOR.ENTER_BR,
ignoreEmptyParagraph: true

}
);
//]]>
</script>

Use in view :
<?php echo $this->Html->script(array('ckeditor/ckeditor', 'ckfinder/
ckfinder')); ?>

<?php echo $this->element('ckeditor', array('name' => 'body', 'id' =>
'body_eng', 'width' => 800, 'height' => 550)); ?>

Hope this will help.



On May 1, 11:32 am, hoss7 <hoss...@gmail.com> wrote:
> this is my sample code for wotk with ckeditor
>
> 1.copy ckeditor in "webroot/js"
>
> 2. in view :
>
> <?php echo $this->Html->script('ckeditor/ckeditor'); ?>
>
> <?php
>         echo
> $this->Form->textarea('info',array('class'=>'ckeditor','id'=>'editor_office2003'));
>     ?>
>     </fieldset>

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: