Typo3 sr_language_menu dropdown not working - typo3

I have installed and configured sr_language_menu(with real_url) in Typo3 6.2.
1.The translation is working, if I use links
But If I use Drop down list the redirection is not happening instead it contains some query string like this
/?tx_srlanguagemenu_languagemenu[__referrer][%40extension]=SrLanguageMenu&tx_srlanguagemenu_languagemenu[__referrer][%40controller]=Menu&tx_srlanguagemenu_languagemenu[__referrer][%40action]=index&tx_srlanguagemenu_languagemenu[__referrer][arguments]=YTowOnt9d9666863629331a07b703f260fec14a2665cc267&tx_srlanguagemenu_languagemenu[__trustedProperties]=a%3A0%3A{}cb8407c7c1f13f96cdceecffd389e5c5a2e8d31c&tx_srlanguagemenu_languagemenu[uri]=de%2Fzuhause%2F
How to hide non translated languages in drop down works fine in links but not working in dropdown(I use ShowInactive=0 in typoscript)

I used the following typoscript to hadle languages
lib.language = HMENU
lib.language {
special = language
special.value = 0,1
1 = TMENU
1 {
wrap =
class="dropdown-toggle" href="#">Language
class="dropdown-menu">|
noBlur = 1
NO {
linkWrap =
|
||
|
stdWrap.override = Nederlands || English
doNotLinkIt = 1
stdWrap.typolink.parameter.data = page:uid
stdWrap.typolink.additionalParams = &L=0 || &L=1
stdWrap.typolink.addQueryString = 1
stdWrap.typolink.addQueryString.exclude = L,id,cHash,no_cache
stdWrap.typolink.addQueryString.method = GET
stdWrap.typolink.useCacheHash = 1
stdWrap.typolink.no_cache = 0
stdWrap.typolink.title = Nederlands || English
}
ACT < .NO
ACT = 1
ACT {
linkWrap =
|
||
class="en_lang active">|
}
}
}
In your custom typo3conf/realurl_conf.php you need to set the languages
according to the id they have
array(
'GETvar' => 'L',
'valueMap' => array(
// id's need to line up with Website Language Ids in TYPO3
// 'nederlands' => '0',
'' => '0',
// 'english' => '1',
'en' => '1',
),
'noMatch' => 'bypass',
)

Related

Typoscript DatabaseQueryProcessor - slide if field is empty

I have a mm relation field in my page settings.
$myext_pages_fields = array(
'tx_myext_topofferitem' => Array(
'label' => 'Relation',
'config' => Array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'tx_myext_topofferitem',
'MM' => 'tt_content_tx_topofferitem_mm',
'size' => '20',
'maxitems' => '99',
'show_thumbs' => '1',
'suggestOptions' => [
'default' => [
'searchWholePhrase' => 1
],
'pages' => [
'searchCondition' => 'doktype = 1'
]
],
)
),
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $myext_pages_fields);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', '--div--;Top Offers,tx_myext_topofferitem');
If the field is empty - the items of the next filled rootline page should be given.
To get the items i use the DatabaseQueryProcessor like that.
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
200 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
200 {
table = tx_myext_topofferitem
pidInList = root,-1
recursive = 99
selectFields = tx_myext_topofferitem.*
join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
where.data = field:uid
where.intval = 1
where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
orderBy = tt_content_tx_topofferitem_mm.sorting
as = tx_myext_topofferitem_items
}
}
}
I tried to use this as where.data, but this does not work.
levelfield : -1 , uid, slide
(TYPO3 9LTS)
It seems that it's better to make use of nested data processing here. So first get a rootline menu and then fetch the items that belong to a specific page of that menu.
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = rootline
special.range = 0|-1
special.reverseOrder = 1
as = rootline
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
if.isTrue.field = tx_myext_topofferitem
table = tx_myext_topofferitem
pidInList.field = uid
selectFields = tx_myext_topofferitem.*
join = tt_content_tx_topofferitem_mm ON tt_content_tx_topofferitem_mm.uid_foreign = tx_myext_topofferitem.uid
where.data = field:uid
where.intval = 1
where.wrap = tt_content_tx_topofferitem_mm.uid_local=|
orderBy = tt_content_tx_topofferitem_mm.sorting
as = tx_myext_topofferitem_items
}
}
}
}
}
}

typo3 language chooser issues after choosing new language

Hi in my typo3 8 website I've added a language chooser. Choosing a language works fine, content switches from german to english it works fine content switches properly.
Issue is when I click a link in english version it always falls back to the german link because /en/ is missing in the Link URL
URL in the Browser looks good the en is there, but in the navigation the URL to an page does not conatin en
I use Typo3 8 and realURL
Typoscript:
config {
sys_language_uid = 0
language = de
locale_all = de_DE.UTF-8
htmlTag_langKey = de
}
config.tx_realurl_enable = 1
[globalVar = GP:L = 1]
config {
sys_language_uid = 1
language = en
locale_all = en_US.UTF-8
htmlTag_langKey = en
}
[global]
temp.langMenu = HMENU
temp.langMenu.special = language
temp.langMenu.special.value = 0,1
temp.langMenu.1 = GMENU
temp.langMenu.1.NO {
XY = [5.w]+4, [5.h]+4
transparentColor = #17353e
backColor = #17353e
5 = IMAGE
5.file = fileadmin/design/images/flag_de.gif || fileadmin/design/images/flag_en.gif
}
temp.langMenu.1.ACT < lib.langMenu.1.NO
temp.langMenu.1.USERDEF1 < lib.langMenu.1.NO
temp.langMenu.1.USERDEF1 = 1
temp.langMenu.1.USERDEF1.5.file = fileadmin/design/images/flag_de.gif || fileadmin/design/images/flag_en.gif
temp.langMenu.1.USERDEF1.noLink = 1
RealURL Config:
<?php
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']=array (
'_DEFAULT' =>
array (
'init' =>
array (
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '/',
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
'firstHitPathCache' => 1,
),
'fileName' =>
array (
'defaultToHTMLsuffixOnPrev' => 0,
'acceptHTMLsuffix' => 1,
'index' =>
array (
'print' =>
array (
'keyValues' =>
array (
'type' => 98,
),
),
),
),
'preVars' =>
array (
0 =>
array (
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'en' => '1',
),
'valueDefault' => 'de',
# 'noMatch' => 'bypass',
),
),
),
);
What is my fail in this case?
Thanks in Advance.
You need to add config.linkVars = L(0-1) to your Typoscript config. This will tell the TYPO3 system to pass this link parameter to each generated url.
Please note that this configuration will only apply to internal links generated by the TYPO3 system itself: For example in menues or when you link another page in the RTE. Absolutely placed links will not be affected by this configuration.
The docs: https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html#linkvars

TYPO3: RealURL Language Switch for Extbase Extension

I have set up a single-domain website with different languages and configured RealURL.
On one page, there is a FE plugin with list and show actions. The links from the list to the show action are rendered correctly, for example:
en/press.html -> en/press/release1.html
en/press.html -> en/press/release2.html
Clicking on one of the links surfaces the detail page - so far, so good. Everything works as expected.
However, the language switch returns the following links (on the detail page):
en/press.html
de/presse.html
The links, of course, should read as follows:
en/press/release1.html
de/presse/aussendung1.html
Also, the breadcrumb menu does not show the detail page; it reads Home > Press, regardless of whether I'm on the list or show action.
Language Nav
temp.langNav = COA
temp.langNav {
10 = HMENU
10 {
special = language
special.value = 0,1,2,3,4,5,6,7,8
special.normalWhenNoLanguage = 0
wrap = <ul class="lang-sel__list">|</ul>
1 = TMENU
1 {
noBlur = 1
NO = 1
NO {
allWrap = <li class="lang-sel__item">|</li>
ATagParams = class="lang-sel__link"
stdWrap.setCurrent = English || Deutsch || Русский || Česky || Polski || Français || Română || Hrvatski || Slovenčina
stdWrap.current = 1
}
USERDEF1 = 1
USERDEF1 {
doNotLinkIt = 1
stdWrap.cObject = TEXT
stdWrap.cObject.value =
}
}
}
}
temp.selectedLang = TEXT
temp.selectedLang.value < config.language
Breadcrumb Nav
temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
wrap = |
1 = TMENU
1.noBlur = 1
1.CUR = 1
1.wrap = |
1.NO {
stdWrap.field = title
ATagParams = class="main-header__breadcrumb-link"
ATagTitle.field = nav_title // title
linkWrap = <li class="main-header__breadcrumb-item">|</li>
}
1.CUR {
stdWrap.field = title
linkWrap = <li class="main-header__breadcrumb-item">|</li>
doNotLinkIt = 1
}
}
}
RealURL Config
$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment';
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'init' => array(
'enableCHashCache' => 1,
'appendMissingSlash' => 'ifNotFile',
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1,
'postVarSet_failureMode' => '',
),
'redirects' => array(),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'en' => 0,
'de' => 1,
'ru' => 2,
'cz' => 3,
'pl' => 4,
'fr' => 5,
'ro' => 6,
'hr' => 7,
'sk' => 8
),
'valueDefault' => 'en',
),
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'spaceCharacter' => '-',
'languageGetVar' => 'L',
'expireDays' => 7,
'rootpage_id' => 1,
'firstHitPathCache' => 1,
),
'fixedPostVars' => array(
'_DEFAULT' => array(
array(
'GETvar' => 'press',
'lookUpTable' => array(
'table' => 'tx_myext_domain_model_press',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
),
'languageGetVar' => 'L',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
)
)
),
'fileName' => array(
'defaultToHTMLsuffixOnPrev' => 1
),
),
);
You need to tell TYPO3 to keep the parameters.
This is done by configuring addQueryString in the HMENU ConentObject.
Your example would be extended by:
temp.breadcrumbNav=COA
temp.breadcrumbNav {
10 = HMENU
10 {
1 {
NO {
addQueryString.exclude = L,cHash
}
}
}
}
For further information check the documentation:
docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Hmenu/Index.html and docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
And the solution above can be found on forge: https://forge.typo3.org/issues/16466#note-3

TYPO3 6.2 performance, Typoscript Select, Typoscript Cache

The problem itself is solved, but the question is still open cause I want to test the tipps from Krystian. See Edit 3 at the bottom of this question.
I have a TYPO3 project that is very slow. So I did some tests and found some problems.
I tested the startpage, the startpage containers 2 news list (total 9 articles) (tx_news version 2.3.0 - not the newest one). It contains the menu (created with fluid v:page.menu), the footer (also created with v:page.menu), a right column (mainly image content elements, gathered from another page with typoscript) and a news-taglist (created with typoscript). The news-taglist is used twice - once in the menu and once in the right column.
First the performance overview:
No Menu/No Footer (without taglist), No News, No Labellist
0.65s
With menu and footer (without taglist)
0.95s
With menu and footer (with taglist)
2.3s
With menu and footer (with taglist) and Taglist in right column
3s
With all
4.2s
A big point is the taglist (right now there is a total of 1303 tags). here is the Typoscript that generate the taglist:
plugin.tx_mytemplate {
newsTags = CONTENT
newsTags {
table = tx_news_domain_model_tag
select {
pidInList = 1,589
hidden = 0
deleted = 0
orderBy = title
}
orderBy = title
renderObj = COA
renderObj {
1 = LOAD_REGISTER
1 {
Counter.cObject = TEXT
Counter.cObject.data = register:Counter
Counter.cObject.wrap = |+1
Counter.prioriCalc = intval
}
2 = TEXT
2.insertData = 1
2 = TEXT
2.insertData = 1
2.field = title
2.typolink {
# link to page
parameter = 588
# the current tag
additionalParams = &tx_news_pi1[overwriteDemand][tags]={field:uid}
additionalParams.insertData = 1
}
2.wrap = <li data-test="{field:uid}" data-index="{register:Counter}">|</li>
}
wrap = <ul>|</ul>
}
}
I use this once in the menu and once in a content element with:
<f:cObject typoscriptObjectPath="plugin.tx_mytemplate.newsTags" />
What I don't understand is, for my understanding there should not be a big difference in using it once or twice (or even more), cause after the first use the typoscript-object should be created and there is no need to create it a second time. Am I missing something here?
This is the SQL:
SELECT * FROM tx_news_domain_model_tag WHERE tx_news_domain_model_tag.pid IN (1,589) AND tx_news_domain_model_tag.deleted=0 AND tx_news_domain_model_tag.hidden=0 ORDER BY title;
It needs 0.004s to execute this query. So the other point I don't understand is, why is it so expensive to create this typoscript-object? Is it the typolink that is used to create all 1303 Links? (I used realURL)
Also, this taglist does not change often, is it somehow possible to full cache it? And for example only create a new taglist when Flush general caches (or frontend cahches) is executed?
Any other ideas? ( I know I could load the taglist via ajax after the page is loaded, but that is just the last work around and maybe there are better solutions)
Edit: I tested the taglist without the typolink and its around 1s faster. That means to create a typolink for 1303 Link costs around 1s.
Edit 2: I found a hidden config.no_cache = 1 And testing right now if everything works when cache is enabled. But anyway I am interessted why typolink is so expensive.
.
Edit 3: I test Krystians answer:
Cache the Typoscript Object with stdWrap.cache.key = someHash
plugin.tx_mytemplate {
newsTags = CONTENT
newsTags {
table = tx_news_domain_model_tag
select {
pidInList = 1,589
hidden = 0
deleted = 0
orderBy = title
}
orderBy = title
renderObj = COA
renderObj {
1 = LOAD_REGISTER
1 {
Counter.cObject = TEXT
Counter.cObject.data = register:Counter
Counter.cObject.wrap = |+1
Counter.prioriCalc = intval
}
2 = TEXT
2.insertData = 1
2 = TEXT
2.insertData = 1
2.field = title
2.typolink {
# link to page
parameter = 588
# the current tag
additionalParams = &tx_news_pi1[overwriteDemand][tags]={field:uid}
additionalParams.insertData = 1
}
2.wrap = <li data-test="{field:uid}" data-index="{register:Counter}">|</li>
}
wrap = <ul>|</ul>
stdWrap.cache.key = mytaglist
stdWrap.cache.lifetime = unlimited
}
}
I can't see any changes in loading time. is there a way to check if this object really gets cached? Did I something wrong?
Using VHS to cache the content with v:render.cache
I replaced
<f:cObject typoscriptObjectPath="plugin.tx_mytemplate.newsTags" />
with
<v:render.cache content="<f:cObject typoscriptObjectPath='plugin.tx_mytemplate.newsTags' />" identity="test1234" />
It seems to work, cause the first call needs longer. But then the next call is "normal" (as I would not use the v.render.cache) until I take the content part out and just use the identify:
<v:render.cache content="test" identity="test1234" />
This is faster and still displays the taglist. So it works so far, that the cached version behind test1234 is used. But it also seems that he render the f:cObject typoscript object in the content part every time. What am I missing here?
Even stranger is, when I use the code with content="test"and flush frontend caches and flush general caches the taglist is still displayed (and not "test"). The docu says: The cache behind this ViewHelper is the Extbase object cache, which is cleared when you clear the page content cache.. What exactly is the page content cache? Not one of the two flush frontend caches or flush general caches ?
Edit 4: With cache enabled I found a problem with the news plugin. I use realURL for the newsplugin:
'category' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][categories]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_category',
'id_field' => 'uid',
'alias_field' => 'CONCAT(title, "-", uid)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
)
)
),
'tag' => array(
array(
'GETvar' => 'tx_news_pi1[overwriteDemand][tags]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_tag',
'id_field' => 'uid',
'alias_field' => 'CONCAT(title, "-", uid)',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-'
)
)
)
),
Calling a category link works without problem, but when I call a tag link then I see only the news from the first hit (changing the tag does not affect anything, it still shows the news filtered by the first tag). So it seems something went wrong there with the cache, but I can not figure out what. For me categories and tag looks pretty much the same, the only difference is another parameter, but realURL should handle that.
Try that:
plugin.tx_mytemplate = TEXT
plugin.tx_mytemplate {
stdWrap.cache.key = mytaglist
stdWrap.cache.lifetime = unlimited
stdWrap.append = CONTENT
stdWrap.append {
# ... your TS
}
}
The first thing you can do is to cache all elements that are common for all pages. Good candidates for that are header and footer elements and in your case maybe the tag list. If you have header done with typoscript then you can use "cache" property of stdWrap.
5 = TEXT
5 {
stdWrap.cache.key = someHash
}
Read the docs here: http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Cache/Index.html
If you use this construction then this element is rendered on first page hit. Then for all next pages when TYPO3 needs to render this element it uses value from cache.
If you think that you can not use it for menu becase you have states like "active"/"current" then you are wrong. You can set the staes using Javascript. Here the example.
var urlSplitted = window.location.pathname.substring(1).split('/');
var urlToCheck = [];
$.each(urlSplitted, function (index, value) {
if (value.length) {
urlToCheck.push(value);
$('#main-nav a').filter(function () {
var match = '^/' + urlToCheck.join('/') + '/$';
if ($(this).attr('href') != undefined) {
return $(this).attr('href').match(new RegExp(match, "i"));
} else {
return false;
}
}).parent().addClass('current');
}
})
If you use Fluid then you can also use such caching of common element. Install ext: vhs and then use this ViewHelper
https://fluidtypo3.org/viewhelpers/vhs/1.1.0/Render/CacheViewHelper.html

TYPO3 language switcher does not use the correct RealURL paths

I use the following TypoScript to generate a language switcher. It's basically a copy from an existing site where everything works fine:
lib.langMenu = HMENU
lib.langMenu {
special = language
addQueryString = 1
special.value = 0,1
special.normalWhenNoLanguage = 0
1 = TMENU
1 {
noBlur = 1
NO = 1
NO {
allWrap = <li>|</li>
stdWrap2.noTrimWrap = | | |
stdWrap.override = Deutsch || English
ATagParams = class="lang-switcher-de" || class="lang-switcher-en"
}
ACT < .NO
ACT = 1
ACT.allWrap = <li class="active">|</li>
wrap = <ul class="pull-right language"><li class="hidden-xs">Language:</li>|</ul>
}
}
Now, I use the following RealURL setup:
$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
'init' => array(
'enableCHashCache' => 1,
'enableUrlDecodeCache' => 1,
'enableUrlEncodeCache' => 1,
),
'preVars' => array (
0 => array (
'GETvar' => 'L',
'valueMap' => array (
'en' => '1',
),
'noMatch' => 'bypass',
),
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
),
)
);
The issue is that, say I have the following pages, with their German and English path:
produkte / products
produktuebersicht / product_overview
When I'm on /produkte/produktuebersicht, the language switcher generates a link to/en/produkte/produktuebersicht instead of /en/products/product_overview. This problem occurs on every single page.
It always takes the path of the wrong (read, current) language. I've checked the ID to path mapping and it looks fine to me:
The encode cache has these entries – but even when I delete them the problem persists:
The weird thing is that the menu itself is generated correctly. So how can I make it link to the right RealURLs in the language switcher?
Your RealURL pagePath section should include a languageGetVar setting.
From the RealURL documentation:
Defines which GET variable in the URL that defines language id; if set the path will take this language value into account and try to generate the path in localized version.
Your pagePath section should look like:
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
'languageGetVar' => 'L'
),