Updated 28 January 2020
With the help of the view_render_event() you can inject anything before or after the content of a template.This is very help full to add any content before or after the content in your template in Bagisto.
You can define any event (view_render_event()) in template by following steps:
Steps:
1- Create an event in the blade file in which you want to render any content before or after any content of that template:
1 |
{{!! view_render_event('bagisto.shop.test.before') !!}} |
As you can see, bagisto.shop.test is event name here that is define in a random blade file of the project.
2- Now you have to listen the event at EventServiceProvider file and in the boot method like:
1 2 3 4 |
Event::listen('bagisto.shop.test.before', function($viewRenderEventManager) { $viewRenderEventManager->addTemplate('template file path that you want to inject);' } |
As you can see, you have to add path of template here that you want to render.
After that this will automatically fire and the your template will be inject before the content.
Make sure that you have registered EventServiceProvider in your ServiceProvider’s.
Hope it will be helpful for you. If you have any issue feel free to raise a ticket at https://bagisto.uvdesk.com/en/
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
2 comments
Greetings!!!
Please post this query once on our forum so our dev can look into it: https://forums.bagisto.com/