Skip to content

Commit

Permalink
Adds multisite support
Browse files Browse the repository at this point in the history
  • Loading branch information
octoberapp committed Jan 6, 2023
1 parent 48f4b2f commit 9c23336
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ public function init()

return $newParams;
});

Event::listen('cms.sitePicker.overrideParams', function ($page, $params, $currentSite, $proposedSite) {
$newParams = $params;
$oldLocale = $currentSite->hard_locale;
$newLocale = $proposedSite->hard_locale;

if (isset($params['slug'])) {
$records = BlogPost::transWhere('slug', $params['slug'], $oldLocale)->first();
if ($records) {
$records->translateContext($newLocale);
$newParams['slug'] = $records['slug'];
}
}

return $newParams;
});
}

public function onRun()
Expand Down

0 comments on commit 9c23336

Please sign in to comment.