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
this will create a category class in `app/Filament/{id of admin panel}/BlockCategories` directory, you can then use this class to group blocks like this:
294
+
295
+
```php
296
+
<?php
297
+
298
+
namespace App\Filament\Admin\BlockCategories;
299
+
300
+
use Redberry\PageBuilderPlugin\Abstracts\BaseBlockCategory;
301
+
302
+
class Buttons extends BaseBlockCategory
303
+
{
304
+
public static function getCategoryName(): string
305
+
{
306
+
return 'Buttons';
307
+
}
308
+
}
309
+
```
310
+
311
+
this classes come more in play when using thumbnail mode of select block, you can read more about it in [Showing thumbnail preview for a block](#showing-thumbnail-preview-for-a-block) section.
blocks can be categorized visually by adding `getCategory` function on a block class, return value of `getCategory` can be either normal string or class that extends `BaseBlockCategory` class, this class can be created by running command:
this will create a category class in `app/Filament/{id of admin panel}/BlockCategories` directory, you can then use this class to group blocks like this:
325
+
326
+
```php
327
+
<?php
328
+
329
+
class Description extends BaseBlock
330
+
{
331
+
public static function getCategory(): string
332
+
{
333
+
return TextFields::class;
334
+
}
335
+
}
336
+
```
337
+
338
+
benefit of using category class is that there is lower chance of a typo on top of this category classes allow more customization when using [thumbnail previews](#showing-thumbnail-preview-for-a-block) for blocks by allowing you to add icons and customized other attributes for a filter tab.
339
+
340
+
you can customize category icon by adding `getCategoryIcon` method to the category class like this:
341
+
342
+
```php
343
+
<?php
344
+
345
+
namespace App\Filament\Admin\BlockCategories;
346
+
347
+
use Redberry\PageBuilderPlugin\Abstracts\BaseBlockCategory;
348
+
349
+
class Buttons extends BaseBlockCategory
350
+
{
351
+
// ...
352
+
353
+
public static function getCategoryIcon(): string
354
+
{
355
+
return 'heroicon-o-hand-raised';
356
+
}
357
+
}
358
+
```
359
+
360
+
and you can customize other tab attributes by overriding `getCategoryAttributes` method like this:
361
+
362
+
```php
363
+
<?php
364
+
365
+
namespace App\Filament\Admin\BlockCategories;
366
+
367
+
use Redberry\PageBuilderPlugin\Abstracts\BaseBlockCategory;
368
+
369
+
class Buttons extends BaseBlockCategory
370
+
{
371
+
// ...
372
+
373
+
public static function getCategoryAttributes(): ComponentAttributeBag
if you want to show thumbnail preview of a block using an image it can be done by declaring `getThumbnail` method on a block class and calling `renderWithThumbnails` method on the page builder field like this:
if you are using categories for blocks it will look like this:
411
+
412
+

413
+
414
+
you can customized tabs by using [Block categories](#block-categories).
296
415
297
416
### disabling block in select block
298
417
if you want to disable block without removing it from the page builder you can do so by declaring `getIsSelectionDisabled` method on a block class like this:
@@ -309,24 +428,6 @@ class Description extends BaseBlock
309
428
}
310
429
```
311
430
312
-
### grouping blocks
313
-
314
-
many times you will have too many blocks and will have the need to group them, this can be done by declaring
iframe height can not be adjusted based on content of iframe because of CORS issues, because of this there are two ways to size iframe height to not cause components to hide.
@@ -473,13 +574,13 @@ this will render preview of items selected in `PageBuilder` field and it will up
473
574
474
575
only component which has actions is `PageBuilder`, all of this actions have their own modifier functions and are moved to the own class, so you can easily customize them, here is the list of actions, functions to modify them and their classes:
one strange thing about this package is how buttons are customized, because of how filamentphp actions are structured each button render comes with lot baggage to say so, multiple views, many checks and etc. while this is not too much of a problem if you are using couple of actions but due to nature of components for building a page there will be need for many many actions, 3 actions per component, its hard to quanitify exactly how much performance disadvantage this causes but in large project we first used this package in it became a massive problem to a point where removing those actions increase paged speeding 2-3 times, same numbers are replicable in this package on smaller scale as well, for example page which was rendering 65 components took around 500ms on local machine with using normal actions and no additional logic on their part while using simple buttons took around 150ms on average because of this drastic performance deference we decided to opt into using simple button rather than action. most buttons are rendered like this:
@@ -504,11 +605,11 @@ as you can see we are using filament button to render our buttons, this gives us
504
605
this buttons can also be easily change, even the component view itself using modifier functions provided on `PageBuilder` component, this functions are injected with: `$action``$item``$index` and `$attributes` which can be injected via passing a closure to the modifier function,
505
606
this is a list of modifier functions and their corresponding actions:
506
607
507
-
| Action name | Modifier function |
508
-
|-------------|-------------------------|
509
-
| Delete |`deleteActionButton`|
510
-
| Edit |`editActionButton`|
511
-
| Reorder |`reorderActionButton`|
608
+
| Action name | Modifier function |
609
+
|-----------|---------------------|
610
+
| Delete |`deleteActionButton`|
611
+
| Edit |`editActionButton`|
612
+
| Reorder |`reorderActionButton`|
512
613
513
614
here is example on how to use this modifier functions:
0 commit comments