打字稿条件 &&条件不工作?

发布于 2024-12-10 08:29:55 字数 487 浏览 0 评论 0原文

这是我的(缩短的)代码:

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

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

我所知道的(所做的):

  • [browser = msie] 单独有效,但对于所有 IE(我需要少于 9 个)
  • 我安装了 conditions 扩展
  • 我搜索了它,但找不到任何完全适合我的问题的

内容 我需要的是一个可以工作的 TS 片段,或者可能是一个解决方法。 谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

奈何桥上唱咆哮 2024-12-17 08:29:55

我知道这个问题很老了,但我刚刚解决了类似的问题。在我的例子中,条件失败了,因为我在这样的块内使用了它:

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]
}

当我重写它时,

# 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]

它开始按预期

工作我正在使用 Typo3 v6.1

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

凯凯我们等你回来 2024-12-17 08:29:55

你的情况看起来是正确的。

那么,也许您有不同的错误?尝试通过测试条件来区分您的问题,而不产生副作用。创建一个新页面,创建一个新的 ts-template 并将此代码放入其中:

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]

现在在浏览器中打开此页面。现在您可以调整您的条件。如果一切正常,则问题出在其他地方。

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.

情绪 2024-12-17 08:29:55

如果您的脚本存储并嵌套在文件系统中(例如使用 INCLUDE_TYPOSSCRIPT),请尝试将您的条件直接插入到您的typo3后端中,在 主模板的设置字段

#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]

您还可以使用 TypoScript 对象浏览器

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.

小梨窩很甜 2024-12-17 08:29:55

问题是 [浏览器 = msie] 不再工作(T3 4.5+)。即使我在 Internet Explorer 中观看,测试设置始终显示条件不满足。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文