Francesco Pellerone
Francesco Pellerone
TCTwill CMS
Created by Francesco Pellerone on 6/25/2024 in #👊support
Missing docs for translated nested modules
Furthermore if you translated the path you should also consider adding the permalinkBase
class PageController extends NestedModuleController
{
//...

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

///default locale ancestor slug
$this->permalinkBase = $item->ancestorsSlug;
///multiple locale ancestor slugs
$locales = config('translatable.locales');
$this->localizedPermalinkBase = [];
foreach (config('translatable.locales') as $locale) {
$baseFolder = \Lang::get('routes.articles', [], $locale);///or whatever your translation is called
$slug = $item->getAncestorsSlug($locale);

$this->localizedPermalinkBase[$locale] = $baseFolder . ($slug != '' ? '/' : '') . $slug;
}

return parent::form($id, $item);
}

)
class PageController extends NestedModuleController
{
//...

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

///default locale ancestor slug
$this->permalinkBase = $item->ancestorsSlug;
///multiple locale ancestor slugs
$locales = config('translatable.locales');
$this->localizedPermalinkBase = [];
foreach (config('translatable.locales') as $locale) {
$baseFolder = \Lang::get('routes.articles', [], $locale);///or whatever your translation is called
$slug = $item->getAncestorsSlug($locale);

$this->localizedPermalinkBase[$locale] = $baseFolder . ($slug != '' ? '/' : '') . $slug;
}

return parent::form($id, $item);
}

)
Note: using setPermalinkBase on setupController was ignored and overridden
2 replies