Question

I've installed the Ivory CKEditor bundle: https://github.com/egeloen/IvoryCKEditorBundle

When I use a ckeditor type field, it loads the HTML on the page, but the javascript assets try to load from a directory that doesn't exist.

My app is located in a non-root directory, so unfortunately the asset files do not reside in /bundles/ivoryckeditor/ckeditor.js, which is where the bundle thinks the assets reside.

I've seen fixes for this multiple times in the project history: https://github.com/egeloen/IvoryCKEditorBundle/pull/1 https://github.com/egeloen/IvoryCKEditorBundle/pull/12

The current code in Resources/views/Form/ckeditor_widget.html.twig uses a custom function:

<script type="text/javascript">
    var CKEDITOR_BASEPATH = "{{ ckeditor_base_path(base_path) }}";
</script>
<script type="text/javascript" src="{{ ckeditor_js_path(js_path) }}"></script>

But for me, this still just creates the incorrect file path I mentioned. In dev there is not dynamic route to /bundles/ directory. And in prod the files exist in a subdirectory for my app, not at the root.

I don't understand asset management very well, so it's possible I'm doing something wrong?

I've posted a github issue about this, but if anyone knows the best solution (short of editing this file myself) I would appreciate it. I don't want to edit the bundle if I can help it.

Was it helpful?

Solution

I will respond here too for others who dig into the same issues :)

You need to provide the assets_base_urls framework configuration as explain here.

For example:

framework:
    templating:
        assets_base_urls: [ "/your/path/prefix" ]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top