Using yii2-ckeditor-widget but missing upload tab and browser, how can I integrate those features ..
I have tried the 2amigos CKEditor Widget for editor.
But cant upload the image though I paste the url of the image.
any solution to get those features in yii2 ?
You need to define your Upload Action:
<?= $form->field($model, 'content')->widget(CKEditor::className(), [
'options' => ['rows' => 6],
'preset' => 'basic'
'clientOptions' => [
'filebrowserUploadUrl' => 'site/url'
]
]) ?>
And there should be your handler for file uploads on this route (http://hosannahighertech.co.tz/blog/mweledi/11-Yii2-CKEditor-and-Images-Upload).
You also can use file manager plugin which have integration with ckeditor:
https://github.com/MihailDev/yii2-elfinder
https://github.com/MihailDev/yii2-ckeditor
Related
I am using the Yii 2 Advanced Application Template, the AdminLTE Asset Bundle and the Gii code generator.
Here is my example:
I need to change the template so I can remove the "Create Lab Tipos Movimientos" button (and modify some things more).
I am removing every button after Gii create the CRUD but I would like to change the template so Gii can do it automatically.
Once you have create your own template for gii
You can change the default template for gii assigning the new template values in main.php (main-local.php)
assigning the proper parameter to gii module
.....
$config['modules']['gii'] = [
//'class' => 'yii\gii\Module',
'class' => 'your_gii_module_path\Module',
'allowedIPs' => ['127.0.0.1', '::1', ],
'generators' => [ //here
'crud' => [ // generator name
//'class' => 'yii\gii\generators\crud\Generator', // generator class
'class' => 'your_gii_module_path\generators\crud\Generator', // generator class
'templates' => [ //setting for out templates
// template name => path to template
'your_crud_entry' => 'your_absolute_path_\your_gii_module_path\generators\crud\default',
]
]
],
];
.......
I have not done it myself, but I found this Guide by SamDark in Github that explains how to create your own template. This is the url: https://github.com/yiisoft/yii2-gii/blob/master/docs/guide/topics-creating-your-own-templates.md
Additionally, if you just want to eliminate the "Create Lab Tipos Movimiento" button you can try modifying the current template which if I am not wrong is located inside the folder vendor/yiisoft/yii2-gii/generators/crud/default/views and the file should be index.php. There you can try deleting or better yet commenting the part of the code that says:
<p>
<?= "<?= " ?>Html::a(<?= $generator->generateString('Create ' . Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>, ['create'], ['class' => 'btn btn-success']) ?>
</p>
I suggest you to make a copy of the files you modify just in case anything goes wrong.
Hope this helps you.
Have a great day.
EDIT:
Additionally following the answer of schmunk to a very similar question in stack overflow found here: How to use custom templates in gii (using Yii 2)
There is apparently a Gii extension in beta phase to help you in this situation called yii2-giiant found here: https://github.com/schmunk42/yii2-giiant (maybe there are similar extensions that are in a more advanced phase of development, google search should help with that)
I have install extension from http://www.yiiframework.com/extension/yii2-latlon-finder/
but is showing me error message "MissingKeyMapError"
I have API key but not sure where to put this.
please help me for same
As i can see, this project is last updated 2 years ago, so it can be outdated with current API's.
As a solution, i can suggest you to use 2amigos - Google Maps extension. It's pretty simple with good documentation.
After installing it, just add this to main.php config file:
'components' => [
'assetManager' => [
'bundles' => [
'dosamigos\google\maps\MapAsset' => [
'options' => [
'key' => 'this_is_my_key',
'language' => 'id',
'version' => '3.1.18'
]
]
]
],
],
Just replace this_is_my_key with your key.
The bad thing in this solution is that you will have to write some additional code to handle user input of lat/long and display it on 2amigos map.
I have a custom contorller called A1Controller which has an action called actionGetdetails. How do I go to this action in the browser? I tried http://localhost/Yii2basicapp/web/a1/getdetails, but it doesn't work.
This is my setting in the web.php file
`'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
['class' => 'yii\rest\UrlRule', 'controller' => 'a1'],
],
],`
Yii expects camelcase actions to be rendered with dashes, so you should access it like http://localhost/Yii2basicapp/web/a1/get-details
You need to use a rest full browser add on to access the rest controller action to work as rest client for You
I use Rest Client Firefox for Firefox You can search for alternative for Your favorite browser
I have an issue about kartik select2 filterType that doesn't work , this is a portion of my code :
[
'format' => ['link',$idmodel],
'attribute' =>$attribute,
'filterType'=>GridView::FILTER_SELECT2,
'filterWidgetOptions' => [
'data' => \yii\helpers\ArrayHelper::map($model_::find()->all(),$attribute,'nom_'.strtolower($idmodel)),
'options' => ['placeholder' => '-'.$idmodel.'-'],
'pluginOptions' => ['allowClear' => true],
'theme' => Select2::THEME_KRAJEE,
],
When i comment this line :
'filterType'=>GridView::FILTER_SELECT2,
a text field appear in my filter grid view.
Can any one help me ??
Thanks in advance
As I see it from your conversation with Edvin Tenovimas your problem is that no jQuery Javascript file is loaded. Did you installed the Select2 package normally with composer?
$ php composer.phar require kartik-v/yii2-widget-select2 "#dev"
In that case you have to see the file vendor/bower/jquery/dist/jquery.min.js. The file has to be copied into your assets directory under web/assets automatically. You could remove the content of the assets directories to force the creation of the assets again.
$ rm -rf web/assets/*
I believe by default GridView enables filtering unless you manually disable it. When you comment that out, it uses default text input instead of Select2. To also disable that one, use this on columns you want to disable filtering:
'filter' => false,
I'd like to insert 2amigos' TinyMCE widget in Kartik's DetailView edit mode. This is what I got by now:
[
'attribute' => 'myAttribute',
'format' => 'raw',
'type' => 'widget',
'widgetOptions' => ['class' => TinyMce::classname()],
'value' => $model->myAttribute,
],
With this chunk I managed to show TinyMCE editor with default settings. What I'm trying to do now is to show it with custom settings defined by:
Yii::$app->params['myTinyMceParams']
In form I'm doing this:
<?= $form->field($model, 'myAttribute')->widget(TinyMce::className(), Yii::$app->params['myTinyMceParams']) ?>
Any ideas?
I finally found a solution, maybe not ideal but fully operative: to merge both 'class' array and rest-of-options array into 'widgetOptions':
'widgetOptions' => ArrayHelper::merge(['class' => TinyMce::classname()], Yii::$app->params['tinyMceParams']),