You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.0/advanced/render-event.md
+17-10Lines changed: 17 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,25 +10,27 @@ The `view_render_event()` function in Krayin allows developers to inject content
10
10
11
11
To utilize the `view_render_event()` function effectively, follow these steps:
12
12
13
-
In this example `admin.contacts.persons.create.header.before` and `admin.contacts.persons.create.header.after` are custom event names that denote where content should be injected before and after the page-header section, respectively inside the `packages/Webkul/Admin/src/Resources/views/contacts/persons/create.blade.php` fie
13
+
In this example, `admin.contacts.persons.edit.form_controls.before` and `admin.contacts.persons.edit.form_controls.after`
14
+
are custom event names that denote where content should be injected before and after the form controls section, respectively inside the `packages/Webkul/Admin/src/Resources/views/contacts/persons/edit.blade.php` file.
15
+
14
16
15
17
### Listening to Events
16
18
17
19
To handle these events and inject content dynamically, you need to listen to them in your application’s event system (typically in the `EventServiceProvider`).
18
20
19
-
Open your `EventServiceProvider.php`file located in `app/Providers`or similar directory.
21
+
Create a file named `EventServiceProvider.php`inside your package’s `Providers` directory:
20
22
21
23
In the `boot()` method of your `EventServiceProvider`, add event listeners as follows:
22
24
23
25
```php
24
26
<?php
25
27
26
-
namespace Webkul\Category\Providers;
28
+
namespace Webkul\<PackageName>\Providers;
27
29
28
30
use Illuminate\Support\ServiceProvider;
29
31
use Illuminate\Support\Facades\Event;
30
32
31
-
class CategoryServiceProvider extends ServiceProvider
33
+
class EventServiceProvider extends ServiceProvider
32
34
{
33
35
/**
34
36
* Register any events for your application.
@@ -37,17 +39,22 @@ class CategoryServiceProvider extends ServiceProvider
Replace `'path/to/before_content_template.blade.php'` and `'path/to/after_content_template.blade.php'` with the actual paths to the Blade template files you want to inject.
52
+
53
+
In this example:
54
+
55
+
- We’re listening to the event: `admin.contacts.persons.edit.form_controls.before` amd `admin.contacts.persons.edit.form_controls.after`.
56
+
- We're dynamically injecting the template: `product::shop.quotes.create` and `product::shop.quotes.view`, where `product` is the supposed namespace of the package and `shop.quotes.create` and `shop.quotes.view` are the view names.
57
+
- The contents of that Blade file will be rendered at the position of the event in the DOM
51
58
52
59
:::warning
53
60
Make sure that you have registered the **`EventServiceProvider`** in your own service provider.
@@ -63,6 +70,6 @@ Replace `'path/to/before_content_template.blade.php'` and `'path/to/after_conten
63
70
64
71
-`Integration`: Integrate this functionality carefully into your Krayin application to maintain coherence and readability of your codebase
65
72
66
-
-`Customization`: Customize event names (`'admin.contacts.persons.create.header.before'`, `'admin.contacts.persons.create.header.after'`) and template paths according to your specific application needs and structure.
73
+
-`Customization`: Customize event names (`'admin.contacts.persons.edit.form_controls.before'`, `'admin.contacts.persons.edit.form_controls.after'`) and template paths according to your specific application needs and structure.
67
74
68
75
By following these steps, you can effectively leverage the `view_render_event()` function in Krayin to dynamically inject content into template sections, enhancing flexibility and customization options within your application.
0 commit comments