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

[FEATURE] Add an option to exclude certain GET variables in the language menu #740

Closed
wants to merge 2 commits into from
Closed
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: 8 additions & 7 deletions Classes/ViewHelpers/Page/LanguageMenuViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function initializeArguments() {
$this->registerArgument('as', 'string', 'If used, stores the menu pages as an array in a variable named according to this value and renders the tag content - which means automatic rendering is disabled if this attribute is used', FALSE, 'languageMenu');
$this->registerArgument('pageUid', 'integer', 'Optional page uid to use.', FALSE, 0);
$this->registerArgument('configuration', 'array', 'Additional typoLink configuration', FALSE, array());
$this->registerArgument('excludeQueryVars', 'string', 'Comma-separate list of variables to exclude', FALSE, '');
}

/**
Expand Down Expand Up @@ -302,16 +303,16 @@ protected function parseLanguageMenu() {
* @return string
*/
protected function getLanguageUrl($uid) {
$getValues = GeneralUtility::_GET();
$getValues['L'] = $uid;
unset($getValues['id']);
unset($getValues['cHash']);
$addParams = http_build_query($getValues, '', '&');
$excludedVars = trim((string)$this->arguments['excludeQueryVars']);
$config = array(
'parameter' => $this->getPageUid(),
'returnLast' => 'url',
'additionalParams' => '&' . $addParams,
'useCacheHash' => $this->arguments['useCHash']
'additionalParams' => '&L=' . $uid,
'useCacheHash' => $this->arguments['useCHash'],
'addQueryString' => 'GET',
'addQueryString.' => array(
'exclude' => 'id,L,cHash' . ($excludedVars ? ',' . $excludedVars : '')
)
);
if (TRUE === is_array($this->arguments['configuration'])) {
$config = ViewHelperUtility::mergeArrays($config, $this->arguments['configuration']);
Expand Down