Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 打字稿中的strpos。在绳子里找到一根针_If Statement_Typo3_Typoscript - Fatal编程技术网

If statement 打字稿中的strpos。在绳子里找到一根针

If statement 打字稿中的strpos。在绳子里找到一根针,if-statement,typo3,typoscript,If Statement,Typo3,Typoscript,打字稿中有类似于strpos的东西吗 我想在另一个字符串中找到一个字符串。如果找到字符串,则应显示COA site.10 = COA site.10 { stdWrap.if.isTrue stdWrap.if.?? } 我不知道如何解决这个问题。好吧,没有任何内置内容可以直接用于打字脚本。但是你可以为自己打造一个小帮手,做同样的事情 示例 # fn.isInString will return true, if the needle was found in string fn.

打字稿中有类似于strpos的东西吗

我想在另一个字符串中找到一个字符串。如果找到字符串,则应显示COA

site.10 = COA
site.10 {


  stdWrap.if.isTrue
  stdWrap.if.??
}

我不知道如何解决这个问题。

好吧,没有任何内置内容可以直接用于打字脚本。但是你可以为自己打造一个小帮手,做同样的事情

示例

# fn.isInString will return true, if the needle was found in string
fn.isInString = COA
fn.isInString {
    1 = LOAD_REGISTER
    1 {
        # REGISTER for what you are looking for
        needle = 

        # REGISTER 
        haystack = 

        # split haystack by the needle
        # result is a haystack without a needle, if found
        findNeedleInHaystack.cObject = TEXT
        findNeedleInHaystack.cObject {
            data = REGISTER:haystack
            split.token.data = REGISTER:needle 
        }
    }

    # compare REGISTER:haystack and result of REGISTER:findNeedleInHaystack
    # if both are the same, nothing was found
    10 = TEXT
    10 {
        # true will be returned, if the needle was found inside haystack
        value = true

        if {
            value.data = REGISTER:haystack 
            equals.data = REGISTER:findNeedleInHaystack

            negate = 1
        }
    }
}


# working example
site = PAGE
site {
    10 = COA
    10 {
        10 = TEXT
        10.value = Your content will apear, if the needle was found in the haystack! :O

        stdWrap.if.isTrue.cObject < fn.isInString
        stdWrap.if.isTrue.cObject.1 {
            needle = needle
            haystack = needle in the haystack
        }
    }
}
如果在字符串中找到指针,则fn.isInstalling将返回true fn.i安装=COA fn.i安装{ 1=加载寄存器 1 { #注册你要找的东西 针= #登记册 干草堆= #用针劈开干草堆 #如果找到了,结果就是一个没有针的干草堆 findNeedleInHaystack.cObject=TEXT findNeedleInHaystack.cObject{ 数据=寄存器:haystack split.token.data=寄存器:指针 } } #比较寄存器:haystack和寄存器结果:findNeedleInHaystack #如果两者相同,则未找到任何内容 10=文本 10 { #如果在干草堆内发现针,则返回true 值=真 如果{ value.data=寄存器:haystack equals.data=寄存器:findNeedleInHaystack 否定=1 } } } #工作示例 站点=第页 场地{ 10=COA 10 { 10=文本 10.value=如果在干草堆中发现了针,则您的内容将消失!:O stdWrap.if.isTrue.cObject 实现这一点还有很多其他方法:

  • 您可以使用适合您需要的东西扩展stdWrap.if
  • 您可以在php中使用带有strps功能的UserFunc

太疯狂了,谢谢。我不知道你可以在TS中做一个函数!如果继续这样下去,总有一天我会理解打字稿的。我不知道,我们是否可以称之为函数,但它就像一个函数一样工作。fn不是一个新单词。我们也可以称之为一系列配置,它们在运行时会失效。(: