twill
twill copied to clipboard
Display nested modules (children) on the dashboard
Summary
I've followed the setup instructions of nested-modules: parent-child-modules.
Let's stick with issues
and articles
, which are children of issues
.
I was able to add issues
to the dashboard as described in the docs under config/twill.php
dashboard.modules
.
<?php
// config/twill.php
return [
'dashboard' => [
'modules' => [
\App\Models\Issue::class => [
'name' => 'issues',
'label' => 'Issues',
'label_singular' => 'Issue',
'count' => true,
'create' => true,
'activity' => true,
'draft' => true,
'search' => true,
'search_fields' => ['title', 'description'],
],
]
]
]

The problem occurs when trying to add the child module in the same way.
<?php
// config/twill.php
return [
'dashboard' => [
'modules' => [
\App\Models\Issue::class => [
'name' => 'issues',
'label' => 'Issues',
'label_singular' => 'Issue',
'count' => true,
'create' => true,
'activity' => true,
'draft' => true,
'search' => true,
'search_fields' => ['title', 'description'],
],
\App\Models\ IssueArticle::class => [
'name' => 'issues.articles',
'label' => 'Articles',
'label_singular' => 'Article',
'count' => true,
'create' => true,
'activity' => true,
'draft' => true,
'search' => true,
'search_fields' => ['title', 'description'],
],
]
]
]

Describe the solution you'd like
I'd like the declaration for these child modules to be similar to their parents.
Since they are depending on their parents and therefore need extra handling a 'nested'
filed in the parents declaration would also work and may even improve the readability of the config.
Additional context
In case the thread disappears:
@AndreSchwarzer I've added the parent to the dashboard
but it seems \A17\Twill\Http\Controllers\Admin\DashboardController can't handle nested modules. Is there a way to make them search and displayable for the dashboard ?
@ifox ha, well for the count option the link wouldn't know where to go as you can't browse all the children in a single screen (unless you've set it up that way, definitely possible with some custom code). For search and activities, we should be able to make that work. Right now you'd need to create some sort of virtual module on top of your child one to make it work it but honestly don't bother with that, create an issue about supporting nested modules in the dashboard and we'll get to it for the count we could still support it without a link
@AndreSchwarzer I'll open an issue and skip it for now thanks