Skip to content

Commit

Permalink
updates to the docs for nested modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldwight authored and ifox committed Jan 9, 2024
1 parent f23eeed commit cbfb508
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions docs/content/1_docs/3_modules/12_nested-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ $slug = $item->getNestedSlug($lang);
To include all ancestor slugs in the permalink of an item in the CMS, you can dynamically set the `$permalinkBase` property from the `form()` method of your module controller:

```php
class PageController extends ModuleController
class PageController extends NestedModuleController
{
//...

protected function form($id, $item = null)
protected function form(?int $id, TwillModelContract $item = null): array
{
$item = $this->repository->getById($id, $this->formWith, $this->formWithCount);

Expand Down Expand Up @@ -71,6 +71,21 @@ Route::get('{slug}', function ($slug) {
For more information on how to work with nested items in your application, you can refer to the
[laravel-nestedset package documentation](https://github.com/lazychaser/laravel-nestedset#retrieving-nodes).

### Setting a maximum nested depth

You can also define the maximum depth allowed for the module changing the following:
```php
protected $nestedItemsDepth = 1;
```
Note: a depth of 1 means parent and child.

### Working with browser fields

By default only a parent item will be visible to the browser field. If you want to show child items when browsing for the module you can set `$showOnlyParentItemsInBrowsers` to false:
```php
protected $showOnlyParentItemsInBrowsers = false; // default is true
```

## Parent-child modules

Parent-child modules are 2 distinct modules, where items of the child module are attached to items of the parent module (e.g. Issues can contain Articles):
Expand Down

0 comments on commit cbfb508

Please sign in to comment.