Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to the docs for nested modules #2389

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading