开发者

Typoscript condition && condition not working?

开发者 https://www.devze.com 2023-04-13 03:36 出处:网络
This is my (shortened) code: lib.nav = COA lib.nav { 50 = HMENU 50 { [ ... ] wrap = <nav>|</nav>

This is my (shortened) code:

lib.nav = COA
lib.nav {
  50 = HMENU
  50 { 
      [ ... ]
  wrap = <nav>|</nav> 
  }
}

[browser = msie] && [version = <9]
lib.nav.50.wrap = <div id="nav">|</div> 
[global]

What I know (did):

  • [browser = msie] alone works but for all IE (I need less than 9)
  • I installed the conditions extension
  • I searched for it but couldn't find anything that would fit exactly my problem

What I need is开发者_高级运维 either a TS snippet that would work or maybe a workaround. Thanks!


I know the question is quite old, but I've just solved similar problem. In my case condition failed because I used it inside a block like this:

config {
    # htmlTag_setParams, adding language and some classes for the Foundation framework
    [browser = msie] && [version =< 9]
    htmlTag_setParams = lang="{$config.language}" class="no-js lt-ie9"
    [else]
    htmlTag_setParams = lang="{$config.language}" class="no-js"
    [global]
}

as soon as I rewritten it as

# htmlTag_setParams, adding language and some classes for the Foundation framework
[browser = msie] && [version =< 9]
config.htmlTag_setParams = lang="{$config.language}" class="no-js lt-ie9"
[else]
config.htmlTag_setParams = lang="{$config.language}" class="no-js"
[global]

it started working as expected

P.S. I'm using Typo3 v6.1


Your condition looks correct.

So, perhaps you have an different error? Try to separate your problems via testing the condition without side-effects. Create a new page, create a new ts-template and put this code into it:

page >
page = PAGE
page.typeNum = 0
page.10 = TEXT
[browser = msie] && [version = <9]
page.10.value = Condition is meet
[else]
page.10.value = Condition is not meet
[global]

Now open this page in your browser. Now you can adjust your Conditions. If everything works, the problem is somewhere else.


If your scripts are stored and nested in the file-system (e.g. with INCLUDE_TYPOSCRIPT), try to insert your condition directly in your typo3 back-end, in the setup field of your main template.

#your previously included file
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/templates/_TypoScript/myTyposcriptFile.ts">

#your condition
page >
page = PAGE
page.typeNum = 0
page.10 = TEXT
[browser = msie] && [version = <9]
page.10.value = Condition is meet
[else]
page.10.value = Condition is not meet
[global]

You can also check if your conditions are working as expected by using the "condition" function at the bottom of the TypoScript Object Browser.


The problem is that the [browser = msie] isn't working anymore (T3 4.5+). The test setup always shows that the condition is not meet even though I'm watching in Internet Explorer.

0

精彩评论

暂无评论...
验证码 换一张
取 消