Hi! I wonder why in GC i cant change some config values dynamically?
For example i need to change ckeditor configuration per controller - i guess change 'grocery_crud_text_editor_type' would be the best solution!
How u think, guys?
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 14 November 2015 - 02:49 AM
Hi! I wonder why in GC i cant change some config values dynamically?
For example i need to change ckeditor configuration per controller - i guess change 'grocery_crud_text_editor_type' would be the best solution!
How u think, guys?
Posted 15 November 2015 - 02:15 AM
Ok, I was investigate this situation and found another solution for change ckeditor config
So all that we will need:
1) custom js ckeditor config file - myckeditor.config.js
$(function() { $('textarea.my-custom-texteditor').ckeditor({ ... here our ckeditor custom config }); });
2)for field that we need custom ckeditor configuration we make callback field where we set our custom class for textarea
public function _my_custom_texteditor($val, $id) { $data = array('id' => 'field-{our field name in POST array}', 'class' => 'my-custom-texteditor', 'value' => $val ); return form_textarea($data); }
3) load our myckeditor.config.js in page where we need custom settings for our custom field
That's it!
P.S. Be aware, if on the page we dont have in GC any text field, then we need to join all files for ckeditor manualy!
Something like this in controller
$this->load->config('grocery_crud'); $editor = $this->config->item('grocery_crud_default_text_editor'); $default_assets_path = 'assets/grocery_crud'; $default_texteditor_path = "$default_assets_path/texteditor"; $default_javascript_path = "$default_assets_path/js"; switch ($editor) { case 'ckeditor': $this->crud->set_js_lib($default_texteditor_path.'/ckeditor/ckeditor.js'); $this->crud->set_js_lib($default_texteditor_path.'/ckeditor/adapters/jquery.js'); $this->crud->set_js_config($default_javascript_path.'/jquery_plugins/config/jquery.ckeditor.config.js'); break; case 'tinymce': $this->crud->set_js_lib($default_texteditor_path.'/tiny_mce/jquery.tinymce.js'); $this->crud->set_js_config($default_javascript_path.'/jquery_plugins/config/jquery.tine_mce.config.js'); break; case 'markitup': $this->crud->set_css($default_texteditor_path.'/markitup/skins/markitup/style.css'); $this->crud->set_css($default_texteditor_path.'/markitup/sets/default/style.css'); $this->crud->set_js_lib($default_texteditor_path.'/markitup/jquery.markitup.js'); $this->crud->set_js_config($default_javascript_path.'/jquery_plugins/config/jquery.markitup.config.js'); break; }
Hope u enjoy, thanks