• Symfony 如何使用ckeditor


    首先:

     1)加载以下两个bundle

    "egeloen/ckeditor-bundle": "^4.0",
    "helios-ag/fm-elfinder-bundle": "^6.2"

    2)注册
    new IvoryCKEditorBundleIvoryCKEditorBundle(),
    new FMElfinderBundleFMElfinderBundle()


    3)配置
    fm_elfinder:
        #assets_path: / # default is /assets, this is where css/js elfinder files are
        instances:
            default:
                locale: "%locale%" # defaults to current request locale
                editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
                #editor_template: custom template for your editor # default null
                #path_prefix: / # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
                #fullscreen: true|false # default is true, applies to simple and ckeditor editors
                #theme: smoothness # jquery theme, default is 'smoothness'
                include_assets: true # disable if you want to manage loading of javascript and css assets manually
                #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
                connector:
                    #debug: true|false # defaults to false
                    roots:       # at least one root must be defined, defines root filemanager directories
                        uploads:
                            #show_hidden: true|false # defaults to false, hides dotfiles
                            driver: LocalFileSystem
                            path: "%kernel.root_dir%/../web/attach/upload/"
                            upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                            upload_deny: ['all']
                            upload_max_size: 10M # also file upload sizes restricted in php.ini
                            url: attach/upload  #这里是你服务器的目录
                            #attributes: example of setting attributes permission
                            #    - { pattern: '/(.*?)/', read: true, write: false, locked: true }

    4)在表单引入

    ->add('content',CKEditorType::class,[
    'label'=>'内容',
    'required'=>true,
    'attr'=>[
    ],
    'config' => array(
    'filebrowserBrowseRoute' => 'elfinder',
    'uiColor' => '#ffffff',
    'filebrowserBrowseRouteParameters' => [
    'instance' => 'default',
    'homeFolder' => ''
    ]
    )
    ])


    5)
    显示内容
    <tr>
    <th>内容</th>
    <td>{{ post.content|raw}}</td>
    </tr>



    如果需要全部代码关注我微信号whenDreams回复"Symfony使用ckeditor",
    或者加QQ群:182983780
    我的微信
  • 相关阅读:
    hadoop 2.5 hdfs namenode –format 出错Usage: java NameNode [-backup] |
    自己动手编译hadoop-2.5.2源码
    CentOS Linux解决Device eth0 does not seem to be present
    Liz Murray成功故事的偶然与必然(转)
    【BZOJ4242】水壶(克鲁斯卡尔重构树,BFS)
    【BZOJ3551】Peaks加强版(Kruskal重构树,主席树)
    【agc023E】Inversions(线段树,动态规划)
    【CF183D】T-shirt(动态规划,贪心)
    【BZOJ2423】最长公共子序列(动态规划)
    【BZOJ2118】墨墨的等式(最短路)
  • 原文地址:https://www.cnblogs.com/Amos-Turing/p/6874179.html
Copyright © 2020-2023  润新知