Skip to content

[FEATURE] Added possibility to disable language redirect for a single site in multisite enviroment #51

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions Classes/Middleware/RedirectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
*/
$cookieName = 'site-language-preference';

/** @var Site $site */
$site = $request->getAttribute('site');

/**
* Do not redirect if site language redirection is disabled for a site
*/
if (
!empty($site->getConfiguration()['SiteLanguageRedirectionDisable']) &&
$site->getConfiguration()['SiteLanguageRedirectionDisable']
) {
return $handler->handle($request);
}

/**
* Do not redirect search engine bots.
*/
Expand All @@ -61,8 +74,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $response;
}

/** @var Site $site */
$site = $request->getAttribute('site');
// Set default method in case site configuration isn't yet updated.
$method = $site->getConfiguration()['SiteLanguageRedirectionMethod'] ?? self::REDIRECT_METHOD_BROWSER;

Expand Down
12 changes: 11 additions & 1 deletion Configuration/SiteConfiguration/Overrides/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@
],
];

$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] = $GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] . ',--div--;Site Language Redirection,SiteLanguageRedirectionMethod';
$GLOBALS['SiteConfiguration']['site']['columns']['SiteLanguageRedirectionDisable'] = [
'label' => 'Disable Redirect',
'description' => 'Disable the language redirect for this site.',
'config' => [
'type' => 'check',
'renderType' => 'checkboxToggle',
'default' => 0,
],
];

$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] = $GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] . ',--div--;Site Language Redirection,SiteLanguageRedirectionDisable,SiteLanguageRedirectionMethod';