简体   繁体   中英

Symfony2 - integration of ckeditor and sonata media bundle

I am trying to integarte IvoryCKEditor with sonata media bundle. Perpose is to allow image uploads in ckeditor. I tried it using a CoopTilleulsCKEditorSonataMediaBundle but i keep getting an error:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_sonata_media_media_ckeditor_browser" as such route does not exist.") in "IvoryCKEditorBundle:Form:ckeditor_widget.html.twig".

Thanks :)

1)安装SonataFormatterBundle 2)在AppKernel中添加bundle及其依赖项3)配置文件4)CLEAR CACHE 5)roll

You should check your routes with the command:

$ php app/console debug:router | grep ckeditor

Then you have to replace admin_sonata_media_media_ckeditor_browser and admin_sonata_media_media_ckeditor_upload by routes founded with this command, in the config of ivory_ck_editor (maybe in your config.yml or your ivory_ckeditor.yml file)

If you don't have route for ckeditor, I think you should check if you install correctly the bundle.

Reason of the issue

This problem arises when trying to integrate CKEditor through the SonataFormatterBundle without using the SonataAdminBundle.

In fact, the integration proposed by the SonataFormatterBundle is meant to only work for the SonataAdminBundle, and no easy integration for a custom admin bundle is currently available.

Note that this dependency is not specified in the documentation at the moment.

How to solve the problem

Simply install the SonataAdminBundle following this installation process . You do need to configure the bundle entirely as specified in the documentation. To add the routes that were missing, such as admin_sonata_media_media_ckeditor_browser , simply add the following to your config/routes.yml :

# This is your custom admin bundle
admin:
    resource: "@AdminBundle/Controller/"
    type:     annotation
    prefix:   /admin/

# Import SonataAdminBundle routes
admin_area:
    resource: "@SonataAdminBundle/Resources/config/routing/sonata_admin.xml"
    prefix: /admin/sonata # put whatever prefix here

_sonata_admin:
    resource:   .
    type:       sonata_admin
    prefix:     /admin

Just to add something.

If you are SURE that you have installed, all dependencies, and set all configs correctly, and still getting this error, then the cause may be that you have defined your 'sonata_media' prefix in routing.yml differently.

You can check all urls in your project in:

 app/cache/dev/appDevUrlGenerator.php

In there you will find ALL routes in a variable $declaredRoutes

Afterwards simply put correct route name for browsing.

It will not work without SonataMediaBundle - you will need to install it with SonataFormatterBundle

Sonata become too complicated as for me, so I just use IvoryCKEditorBundle directly

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM