Page crashes when attaching a custom stylesheet to the active theme



  • Hi. I am following the guides in this link to implement a HelloWorld package:
    https://devdocs.bagisto.com/create_package.html#how-to-create-package

    When I use the following code to add the stlesheeto to admin template everything is OK (HelloWorldServiceProvider.php):

    use Illuminate\Support\Facades\Event;
    public function boot()
    {
        Event::listen('bagisto.admin.layout.head', function($viewRenderEventManager) {
            $viewRenderEventManager->addTemplate('helloworld::helloworld.layouts.style');
        });
    }
    

    But when I change the code to use velocity temmplate the page does not load completely:

    public function boot()
    {
        Event::listen('bagisto.shop.layout.head', function($viewRenderEventManager) {
            $viewRenderEventManager->addTemplate('helloworld::helloworld.layouts.style');
        });
    }
    

    Here is my /views/helloworld/helloworld.blade.php :

    @extends('shop::layouts.master')
    @section('full-content-wrapper')
    <h1>Hello World</h1>
    @endsection
    

    I noticed that the following code causes the shop.css file to crash.

    Event::listen('bagisto.admin.layout.head', function($viewRenderEventManager) {
            $viewRenderEventManager->addTemplate('helloworld::helloworld.layouts.style');
        });
    

    when I navigate to other pages everything is OK but in case of http://localhost:8000/hello-world the rendered page tries load shop.css file from a wrong location. Actually I should get:

    <link rel="stylesheet" href="http://localhost:8000/themes/default/assets/css/shop.css">
    

    But I am getting:

    <link rel="stylesheet" href="http://localhost:8000/css/shop.css">
    



Log in to reply