Recent Topics

viewRenderEventManager add template with params



  • How can I inject a view using the Events listeners, and viewRenderEventManager but with some dynamic parameters?
    Something like:
    Event::listen('bagisto.shop.layout.head', function ($viewRenderEventManager) {
    $viewRenderEventManager->addTemplate('gtmanager::gtm.head', ['param1' => $param]);
    });

    So I need to insert the view ('gtmanager::gtm.head') from my custom module in the 'bagisto.shop.layout.head' location with the parameter 'param1'

    Any idea how can I achieve something like this?

    Thanks!



  • Hello @Vlad99 ,
    You can use the view->composer() in your service provider to pass any parameter to the blade where this view_render_event(bagisto.shop.layout.head) is already defined, after that inject your template and you can access the parameter in template that you have passed in viewComposer.

    Thanks!



  • You can check the AdminServiceProvider under The Admin Package for the reference.


Log in to reply