Yii Framework Forum: integracion del ckeditor - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

integracion del ckeditor Rate Topic: -----

#1 User is offline   blueguy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 25-April 11

Posted 29 September 2011 - 11:03 AM

Hola espero me puedan ayudar, integre el ckeditor al yii pero deseo personalizar la barra de herramientas y observe que tiene tres opciones como basic, full, advance en la advance no me muestra nada y me gustaria saber como hacer para yo poder personalizarlo.

Gracias!!!

Lindo dia!!!
0

#2 User is offline   Jose G. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 24-September 11
  • Location:Tampa, FL

Posted 29 September 2011 - 12:10 PM

Hi blueguy,

Here is a little widget I started. Nothing big. Here is how I have it setup:

/protected/components/WCKeditor.php
/protected/components/WCKeditor/config.js <- my own custom config for CKEditor
/protected/components/WCKeditor/ckeditor <- CKEditor downloaded from the official site.
/protected/components/WCKeditor/ckeditor/ <- You should end up with CKeditor's files here (example: ckeditor.js).

In your view with the form:

<?php $this->widget('WCKeditor', array( 'model' => $model, 'attribute' => 'body',)); ?>


WCKEditor.php (CInputWidget):

<?php

class WCKeditor extends CInputWidget
{

  /**
   * @var string Path to the WCKEditor assets folder.
   */
  public $assetDir;

  /**
   * @var string Absolute URL of the published assets folder.
   */
  public $publishUrl;

  /**
   * @var boolean Use the CKeditor's jQuery adapter
   */
  public $usejQuery = TRUE;

  /**
   * Initialize the Widget
   */
  public function init() {
    parent::init();
    $this->assetDir = $this->assetDir ? $this->assetDir : dirname(__FILE__) . '/WCKeditor';
    $this->publishUrl = Yii::app()->getAssetManager()->publish($this->assetDir);
  }

  /**
   * Run the widget
   */
  public function run() {
    list($name, $id) = $this->resolveNameID();

    if ( isset($this->htmlOptions['id']) ) $id = $this->htmlOptions['id'];
    else $this->htmlOptions['id'] = $id;
    if ( isset($this->htmlOptions['name']) ) $name = $this->htmlOptions['name'];

    /* @var $cs CClientScript */
    $cs = Yii::app()->clientScript;
    $cs->registerScriptFile($this->publishUrl . '/ckeditor/ckeditor.js', CClientScript::POS_END);

    if ( $this->usejQuery ) {
      $cs->registerScriptFile($this->publishUrl . '/ckeditor/adapters/jquery.js', CClientScript::POS_END);
      $script .= '$(\'#'. $id .'\').ckeditor({customConfig: \''. $this->publishUrl .'/config.js\'});';
    }
    else {
      $script .= 'CKEDITOR.replace(\''. $id .'\', {customConfig: \''. $this->publishUrl .'/config.js\'});';
    }

    $cs->registerScript('WCKEditor_'. $id, $script, CClientScript::POS_LOAD);

    if ( $this->hasModel() ) echo CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions);
    else echo CHtml::textArea($name, $this->value, $this->htmlOptions);
  }



}



0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users