MrRap
MrRap

Reputation: 137

Typoscript condition && condition not working?

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):

What I need is either a TS snippet that would work or maybe a workaround. Thanks!

Upvotes: 1

Views: 2232

Answers (4)

Grumpy Old Bastard
Grumpy Old Bastard

Reputation: 31

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.

Upvotes: 0

Gianpaolo Scrigna
Gianpaolo Scrigna

Reputation: 862

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.

Upvotes: 0

Anton Boritskiy
Anton Boritskiy

Reputation: 1569

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

Upvotes: 2

maholtz
maholtz

Reputation: 3631

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.

Upvotes: 1

Related Questions