简体   繁体   English

Typo3缓存未与globalVar打字条件一起使用

[英]Typo3 cache not used with globalVar typoscript condition

I have a multi language Typo3 (7.6.22) setup which causes some caching problems. 我有一个多语言Typo3(7.6.22)设置,这会导致一些缓存问题。 If I use the following TypoScript condition, only the first accessed language page gets cachhed. 如果我使用以下TypoScript条件,则仅访问第一个访问的语言页面。

[globalVar = LIT:0 < {$lib.sys_language_uid}]
lib.lang.home_action.value = http://{$lib.url.domain}{$lib.url.basePath}{$lib.language}.html
[global]

with $lib.sys_language_uid defined this way $lib.sys_language_uid通过这种方式定义

[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
[globalVar = GP:L = 2]
lib.sys_language_uid = 2
[global]
...

I now wondering, what causes this problem and how I could solve this, without putting the condition inside my fluid templates. 我现在想知道是什么原因导致这个问题,以及如何在不将条件放入流体模板的情况下解决该问题。

I think the problem occurs as your conditions are very complicated to evaluate. 我认为问题是因为您的条件评估非常复杂。

Caching in TYPO3 is done for each condition evaluation (true - false). TYPO3中的缓存针对每个条件评估完成(是-否)。
ATM I can't say whether conditions in the Constants part are enough to make up separate caches. 我不能说ATM常量部分中的条件是否足以构成单独的缓存。 and also unclear if the evaluation with (changing) constants [*] will create separate caches. 并且也不清楚带有(更改)常量[*]的评估是否将创建单独的缓存。

let's see what will happen with differnt values for URL parameter L: 让我们看看使用不同的URL参数L值会发生什么:

&L=0 (or not set) &L = 0(或未设置)
in constant part no condition is true, so lib.sys_language_uid does not get set at all. 在恒定的部分,没有条件为真,因此lib.sys_language_uid根本不会设置。
So in setup we have: 因此在设置中,我们有:

[globalVar = LIT:0 < {$lib.sys_language_uid}] 

and this is literally ( 0 < '{$lib.sys_language_uid}' ) as the constant is not defined. 由于没有定义常量,因此它的字面意义是( 0 < '{$lib.sys_language_uid}' )。 So it evaluates to TRUE . 因此它的评估结果为TRUE

&L=1 &L = 1
constants: 常量:

[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]

this part is true and we have lib.sys_language_uid set to 1 . 这部分是正确的,我们将lib.sys_language_uid设置为1

in setup we now have the condition 在设置中,我们现在有了条件

[globalVar = LIT:0 < 1] 

which also evaluates to true. 这也评估为true。

&L=2 &L = 2

[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]
[globalVar = GP:L = 2]
lib.sys_language_uid = 2
[global]

both parts are true and we have lib.sys_language_uid set to 2 . 这两部分都是正确的,我们将lib.sys_language_uid设置为2

in setup we now have the condition 在设置中,我们现在有了条件

[globalVar = LIT:0 < 2] 

which also evaluates to true. 这也评估为true。

&L=3 (or further values) constants: &L = 3(或其他值)常量:

[globalVar = GP:L > 0]
lib.sys_language_uid = 1
[global]

only the first part is true and we have lib.sys_language_uid set to 1 . 只有第一部分为真,并且我们将lib.sys_language_uid设置为1

in setup we now have the condition 在设置中,我们现在有了条件

[globalVar = LIT:0 < 1] 

which also evaluates to true. 这也评估为true。
This is the same condition as for &L=1 and this will use the same cache! &L=1条件相同,并且将使用相同的缓存! BOOM!! 繁荣!!

Result: 结果:
[*] changing constants is a bad concept! [*]更改常量是一个坏概念!

use the evaluation of the URL-Parameter in the setup part of TS templates instead of crypt it in the constants part. 请在TS模板的设置部分中使用对URL参数的求值,而不是在常量部分中对其进行加密。

It is may the naming convention, but usually things with "lib." 它可能是命名约定,但通常带有“ lib”的名称。 are defined in the setup section. 在设置部分中定义。

[globalVar = LIT:0 < {$lib.sys_language_uid}] 

If it is the case and you defined it there, then it is a problem, because its value stays the same independent from the language. 如果是这种情况,并且在此处定义了它,那么这就是问题所在,因为它的值与语言无关而保持不变。 The condition "LIT" can handle only constants. 条件“ LIT”只能处理常量。

{$lib.sys_language_uid} should be a constant. {$lib.sys_language_uid}应该是一个常数。

BTW BTW

If I have such a problem I always try to "print" the value of that TypoScript constant or cObject into the markup, like: 如果遇到这样的问题,我总是尝试将TypoScript常数或cObject的值“打印”到标记中,例如:

page.headerData.123456 = TEXT
page.headerData.123456 { 
    value = {$lib.sys_language_uid}
    wrap = <test>|</test> 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM