Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle tries to load its JS resources using invalid URL #161

Closed
mikemix opened this issue Jun 26, 2018 · 5 comments
Closed

Bundle tries to load its JS resources using invalid URL #161

mikemix opened this issue Jun 26, 2018 · 5 comments

Comments

@mikemix
Copy link
Contributor

mikemix commented Jun 26, 2018

When I enter any form within this bundle (either block form or page form) bundle tries to load its JS resources using invalid URL:

Page at:
http://localhost:8080/app_dev.php/admin/pages/new

Requested resources (with 404 error):
http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-page-slug.js
http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-page-slug.js

Page at:
http://localhost:8080/app_dev.php/admin/blocks/new/image

Requested resources (with 404 error):
http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-block-image-preview.js
http://localhost:8080/bundles/_themes/[theme_name]/default/bitbagsyliuscmsplugin/js/bitbag-block-image-preview.js

Yep, both are requested twice lol. The base path for the resources should be: /bundles. This is my directory structure:

Directory structure

I'm using:

        "php": "^7.1",
        "bitbag/cms-plugin": "^1.3",
        "sylius/sylius": "1.2.*",
        "symfony/symfony": "^3.4|^4.1"
@mikemix
Copy link
Contributor Author

mikemix commented Jun 26, 2018

This is how: Sylius\Bundle\ThemeBundle\Asset\Package\PathPackage works. If requested asset is not an absolute URL, it merges the path with the theme context if one is set:

        if ($this->isAbsoluteUrl($path)) {
            return $path;
        }

        $theme = $this->themeContext->getTheme();
        if (null !== $theme) {
            $path = $this->pathResolver->resolve($path, $theme);
        }

@mikemix
Copy link
Contributor Author

mikemix commented Jun 26, 2018

My bad :D 🗡️

@mikemix mikemix closed this as completed Jun 26, 2018
@bitbager
Copy link
Member

Anyway, thanks for the information. There were many people in the community that had problems with theming in this plugin. CC @patrick477.

@mikemix
Copy link
Contributor Author

mikemix commented Jun 26, 2018

Well the sylius:theme:assets:install command has to be called. I have now duplicated assets which doesn't make any sense but fkit ;)

@bitbager
Copy link
Member

We will mention it in the README. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants