RoxyMce - Beautiful File manager for Tinymce ¶
This allow to integrate TinyMce 4 with Roxy File Manager
Install ¶
Preferred way to install this extension through composer
Either run
~~~
composer require navatech/yii2-roxymce "^2.0"
~~~
Or add to require
section of composer.json
then run composer update
~~~
"navatech/yii2-roxymce" : "^2.0"
~~~
Configure & Usage ¶
Configure module ¶
Property ¶
uploadFolder
the directory where stored file. Default is@app/web/uploads/images
. If folder not existed, roxy will auto-create it.defaultView
display type. Default isthumb
dateFormat
Datetime format. Default isY-m-d H:i
. See: http://php.net/manual/en/function.date.phprememberLastFolder
would you want to remember last folder? Default istrue
rememberLastOrder
would you want to remember last order? Default istrue
allowExtension
allowed files extension. Default isjpeg jpg png gif mov mp3 mp4 avi wmv flv mpeg webm
Example ¶
Add to config file:
`
'modules' => [
'roxymce' => [
'class' => 'navatech\roxymce\Module',
'uploadFolder' => '@frontend/web/uploads/images',
],
],
## Widget Usage
### Property
* `model` Instance of Model|ActiveRecord. **Required** if `name` has not been defined.
* `attribute` attribute name in your model. **Required** if `name` has not been defined & when `model` has been defined.
* `name` input's name. **Required** if `model` & `attribute` has not been defined.
* `value` default value of tinymce. **Not required** Default is value of `$model->$attribute` or `empty` when not using `model` section
* `action` default is ` Url::to(['/roxymce/default/index'])` **Not required**
* `options` default options of textarea. **Not required**. See: [Html::textarea()](http://www.yiiframework.com/doc-2.0/yii-helpers-basehtml.html#textarea()-detail)
* `clientOptions` Tinymce options. **Not required**. See: https://www.tinymce.com/docs/
* `title` Title bar of roxymce iframe. **Not required**
### Example
In your view file, call roxymce widget
#### Include ActiveRecord Model
```php
echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
'model' => app\models\Post::findOne(1),
'attribute' => 'content',
]);
Sample HTML without ActiveRecord Model ¶
echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
'name' => 'Post[content]'
]);
Screenshot ¶
Resource ¶
Bugs & Issues ¶
Found some bugs? Just create an issue or fork it and send pull request
Looking for help
I installed the extension as described above, simple config ind web.php and calling roxymce widget in the create / update view file.
The extension is installed by composer.
When calling the view I get a "Class 'navatech\roxymce\widgets\RoxyMceWidget' not found" error.
Here is the code:
~~~
$this->title = Yii::t('app', 'Create Static Content'); $this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Static Contents'), 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title;
?>
<div class="static-content-create"> <h1><?= Html::encode($this->title) ?></h1> <?php echo \navatech\roxymce\widgets\RoxyMceWidget::widget([ 'model' => $model, ]); ?> <?= $this->render('_form', [ 'model' => $model, ]) ?> </div>
Would appreciate any help even directly to post@netzw.de, thanks.
maybe composer install failed
@clauer
Could you please send to me composer.lock?
or make sure:
Thanks for using.
Files
@TuoiTeen
I did send you the composer.lock and two other files describing the issue in detail by email in return to your email.
Thanks for helping
no email received
@clauer
I just check my inbox at info@navatech.vn, and no email from you there.
Can you push it to pastebin.com and post here?
Content of my email
@TuoriTeen
Thanks for your quick answer.
Seems the error has another reason. Below you may find the stack after calling roxymcewidget, the entry in config/web.php, the content of the folder below vendor and the source of the model StaticContent. The stack reports that an attribute is missing but I don't know exactly which one.
Regards
Christian Lauer
Stack
~~~
in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\widgets\RoxyMceWidget.php at line 55
46474849505152535455565758596061626364
*/
public function init() {
parent::init();
TinyMceAsset::register($this->view);
if ($this->model !== null) {
if ($this->attribute === null) { throw new InvalidParamException('Field "attribute" is required'); } else { $model = $this->model; if (method_exists($model, 'hasAttribute') && $model->hasAttribute($this->attribute)) { $this->id = $model::tableName() . '_' . $this->attribute; } else { throw new InvalidParamException('Column "' . $this->attribute . '" not found in model'); } }
} else {
9101112131415161718192021
/ @var $form yii\widgets\ActiveForm /
?>
<?php
echo \navatech\roxymce\widgets\RoxyMceWidget::widget([
'model' => $model,
]);
<?php $form = ActiveForm::begin(); ?> 9. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 325 – require('D:\Web\htdocs\wsk\wsk\test\unser...') 10. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 247 – yii\base\View::renderPhpFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent]) 11. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 149 – yii\base\View::renderFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent], null) 12. in D:\Web\htdocs\wsk\wsk\test\unserCMS\views\static-content\create.php at line 19 – yii\base\View::render('_form', ['model' => app\models\StaticContent]) 131415161718192021?>
<?= Html::encode($this->title) ?>
<?= $this->render('_form', [ 'model' => $model, ]) ?> 13. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 325 – require('D:\Web\htdocs\wsk\wsk\test\unser...') 14. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 247 – yii\base\View::renderPhpFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent]) 15. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\View.php at line 149 – yii\base\View::renderFile('D:\Web\htdocs\wsk\wsk\test\unser...', ['model' => app\models\StaticContent], app\controllers\StaticContentController) 16. in D:\Web\htdocs\wsk\wsk\test\unserCMS\vendor\yiisoft\yii2\base\Controller.php at line 377 – yii\base\View::render('create', ['model' => app\models\StaticContent], app\controllers\StaticContentController) 17. in D:\Web\htdocs\wsk\wsk\test\unserCMS\controllers\StaticContentController.php at line 82 – yii\base\Controller::render('create', ['model' => app\models\StaticContent]) 76777879808182838485868788 if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } } /** * Updates an existing StaticContent model. * If update is successful, the browser will be redirected to the 'view' page. 18. app\controllers\StaticContentController::actionCreate() ~~~ config/web.php - within modules: ~~~ 'roxymce' => [ 'class' => '\navatech\roxymce\Module', ] ~~~ Content of the Folder in the vendor folder ~~~ T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src DIR FontAwesomeAsset.php JqueryDateFormatAsset.php Module.php RoxyMceAsset.php TinyMceAsset.php T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\css DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\css\images DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images\filetypes DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\images\filetypes\big DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\js DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\assets\lang DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\controllers DIR DefaultController.php ManagerController.php T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\helpers DIR FileHelper.php ImageHelper.php RoxyHelper.php T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\views DIR T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\views\default DIR index.php T:\htdocs\wsk\wsk\test\unserCMS\vendor\navatech\yii2-roxymce\src\widgets DIR RoxyMceWidget.php ~~~ Source of StaticContent.php (model) ~~~ <?php namespace app\models; use Yii; use yii\db\ActiveRecord; /** * This is the model class for table "static_content". * * @property integer $id * @property integer $linked * @property string $headline * @property string $menu_entry * @property string $author * @property string $creation_date * @property string $last_change * @property string $text * @property string $images * @property string $links_int * @property string $links_ext * @property string $downloads */ class StaticContent extends ActiveRecord { /** * @inheritdoc */ public static function tableName() { return '{{%static_content}}'; } /** * @inheritdoc */ public function rules() { return [ [['linked'], 'integer'], [['headline', 'text', 'images', 'links_int', 'links_ext', 'downloads'], 'required'], [['headline', 'text', 'images', 'links_int', 'links_ext', 'downloads'], 'string'], [['creation_date', 'last_change'], 'safe'], [['menu_entry', 'author'], 'string', 'max' => 30] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('app', 'ID'), 'linked' => Yii::t('app', 'Linked'), 'headline' => Yii::t('app', 'Headline'), 'menu_entry' => Yii::t('app', 'Menu Entry'), 'author' => Yii::t('app', 'Author'), 'creation_date' => Yii::t('app', 'Creation Date'), 'last_change' => Yii::t('app', 'Last Change'), 'text' => Yii::t('app', 'Text'), 'images' => Yii::t('app', 'Images'), 'links_int' => Yii::t('app', 'Links Int'), 'links_ext' => Yii::t('app', 'Links Ext'), 'downloads' => Yii::t('app', 'Downloads'), ]; } /** * @inheritdoc * @return StaticContentQuery the active query used by this AR class. */ public static function find() { return new StaticContentQuery(get_called_class()); } } ~~~Field "attribute" is required
look like you use RoxyWidget with model ActiveRecord, so you missing field "attribute"
~
`
phpecho \navatech\roxymce\widgets\RoxyMceWidget::widget([
'model' => $model, //your Model, REQUIRED 'attribute' => 'content', //attribute name of your model, REQUIRED if using 'model' section
Need help please
Hi,
I just installed navatech roxymce sucessfully with composer in yii2 advanced app.
Directory structure of the site (absolute paths):
Application: www/htdocs/user/test/yii-adv
Web root: www/htdocs/user/test/yii-adv/backend/web
Files folder: www/htdocs/user/test/yii-adv/files
How to configure the param FILES_ROOT in config that it points to the files folder? With every value I set, even the absolute path, a new folder is created which looks like www/htdocs/user/test/yii-adv/www/htdocs/user/test/yii-adv/...
Would appreciate any help even directly to post@netzw.de, thanks!
Christian
Need help please, bug?
Hi,
there seems to be a bug in both Module.php and RoxyHelpers.php which prevents from getting the right base directory for uploaded files.
Modules.php line 85:
replace $FilesRoot = RoxyHelper::fixPath(RoxyHelper::getBasePath() . RoxyHelper::getFilesPath());
with $FilesRoot = RoxyHelper::fixPath(RoxyHelper::getFilesPath());
RoxyHelpers.php static function getFilesPath() line 204
replace $ret = FileHelper::fixPath(RoxyHelper::getBasePath() . Yii::getAlias('@web/') . FILES_ROOT);
with $ret = FileHelper::fixPath(Yii::getAlias('@web/') . FILES_ROOT);
otherwise the basePath or @web would be doubled.
Regards
Christian
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.