Yii 1.1: yii-aloha-editor

Yii Widget for the Aloha Editor
11 followers

Yii-Aloha-Editor-Widget

Yii Widget for the Aloha Editor

Requirements

  • JQuery > 1.7.1
  • Browser:
    • Firefox 3+
    • Safari 4+
    • Chrome 4+
    • Opera 10+
    • IE 7+

Installation

  1. Download or Clone the files
  2. Extract into the widgets folder or extensions folder

Usage

Using with a model

$this->widget('application.widgets.alohaeditor.AlohaEditor', array( 'model' => $model, 'attribute' => 'some_attribute', 'showTextarea' => true ));
  • By default 'showTextarea' is set to false

Using selector to set multiple elements editable

$this->widget('application.widgets.alohaeditor.AlohaEditor', array( 'selector' => '.editable' ));

Using with a model and a basic toolbar

$this->widget('application.widgets.alohaeditor.AlohaEditor', array('toolbar' => 'basic', 'model' => $model, 'attribute' => 'some_attribute' ));
  • There are two toolbars supported right now: basic and advanced
  • At any point you can add more plugins to the toolbar by assigned array elements to the plugins property in the widget

Using with a model and a basic toolbar and custom plugins

$this->widget('application.widgets.alohaeditor.AlohaEditor', array('toolbar' => 'basic', 'plugins' => array('extra/hints'), 'model' => $model, 'attribute' => 'some_attribute' ));

Using with a model and a basic toolbar and custom editor settings

$this->widget('application.widgets.alohaeditor.AlohaEditor', array('alohaSettings' => array('lang' => 'fr'), 'model' => $model, 'attribute' => 'some_attribute' ));
  • Supported languages currently: de, en, fr, lv, pl, pt_br, ru, ua
  • Refer to the documentation for a list of supported params for the settings array

Using with a name and value

$this->widget('application.widgets.alohaeditor.AlohaEditor', array( 'name' => 'some name', 'value' => 'some value' ));

Authors

Vincent Gabriel http://vadimg.com

Total 7 comments

#11861 report it
Blue Spy at 2013/02/08 03:16am
Using with model database

Hi, I have been trying to use this extension for quite a while, but I can't get it to running somehow.

I tried the widget by calling

$this->widget('application.widgets.alohaeditor.AlohaEditor', array( 'model' => $model, 'attribute' => 'some_attribute', 'showTextarea' => true ));

But when I check the source, my model doesn't seem to be loaded anywhere. Am I missing something?

#9746 report it
David Dreggors at 2012/09/08 12:58am
Thanks

Sorry for the late reply but I will pull it from the repo now.

Edit The changes are there and work great.

Thanks

#9657 report it
Vince. at 2012/09/01 06:03pm
You'll need to pull from the repo to see the fixes. I just used your suggestions and used local copies instead of the CDN ones.

You'll need to pull from the repo to see the fixes. I just used your suggestions and used local copies instead of the CDN ones.

#9656 report it
Vince. at 2012/09/01 06:02pm
Thank You.

This is now fixed. You can pull from the repo to see the fixes.

Thanks.

#9638 report it
David Dreggors at 2012/08/31 02:08am
On the contrary...

My experience is great now that these scripts are registered in Yii.

The points about using cdn vs local for css are all user preference I understand that, but you did not mention the 2 scripts and the fact that you must register them with Yii. Will you fix that?

Yii does not automatically load and use scripts just because you reference it later in code. You must register as I have show in my previous post. If yours has worked it is only because something else may be registering it in your test case.

With Yii 1.1.12 and a brand new web app created with "yiic webapp blah" I can confirm that calling the widget in a page as you have suggested doe NOT load the scripts. After making the changes I mention I now see the following in the source code of my page:

<link rel="stylesheet" type="text/css" href="/assets/d9d1913b/css/aloha.css" />
<script type="text/javascript" src="/assets/68368b44/jquery.js"></script>
<script type="text/javascript" src="/assets/68368b44/jui/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/assets/d9d1913b/lib/require.js"></script>

Prior to my addition I only saw the aloha.css entry.

All of these scripts are needed. Aloha Editor's site has a guides section that describes this in detail in section 5:

Using Aloha Editor

EDIT I am home now, not behind the corporate proxy. This is definitely a proxy issue. Maybe documenting these issues/fixes in the form of comments can help others behind a proxy would be helpful?

Again, great widget! I find it great for allowing non-technical staff to edit content on static pages as well. I know, odd usage but it is very helpful to let office staff update portions of web pages that need changing often.

#9636 report it
Vince. at 2012/08/30 10:24pm
Sorry if you didn't have a good experience working with this extension.

The reason i used the CDN is because they update their stylesheet often, So instead of keep updating the extension or telling the users to update it i thought using the CDN will be easier, Apparently for some it's not. I've had no problems with this, Obviously some users need to modify it to fit their needs, I think this is one of those cases.

#9631 report it
David Dreggors at 2012/08/30 02:49pm
Code additions

I had a nothing but trouble seeing and using the aloha toolbar with this widget. I discovered it was because your widget does not register 'jquery.ui' or the aloha 'require.js' scripts with Yii!

In your widget's main entry script (AlohaEditor.php) I added these lines right under the line where you register the aloha css file...

// Register the JQuery UI script
$cs->registerCoreScript('jquery.ui');
 
// Register the Aloha require.js
$cs->registerScriptFile($assets.'/lib/require.js')

Please also not that I use your "$assets" variable to point to the 'require.js', and I used the Yii core jquery ui script and not the cdn version. Also, I personally chose to change the css line as well to the following.

// Register the css through the aloha cdn network as they update it often
$cs->registerCSSFile($assets.'/css/aloha.css');

Again you will see that I use your variable "$assets" and append the rest of the path. If you already have the css and js files under the aloaeditor tree, then why point to an external source (aloha cdn)?

By using the local source already installed you avoid issues with proxies, host side path changes, version differences, and many more. In my case I am behind a proxy and my web server has issues reaching out to a remote file for inclusion. Many production networks are setup that way. You might consider the points I make as a sane default and add in that one can change these as needed. ;-)

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet