Home > Software design >  If the variable contains text within the string | HTML
If the variable contains text within the string | HTML

Time:08-26

I currently use this html code {{ou.user_agent}}

Which results in the build which results in the user agent.

To identify an exact word I do this {{ou.user_agent == "Store" ? "Go" : "Nope"}}

If the user agent contains Store exactly, it returns Go and if it does not, it returns Nop.

The problem with this is that it requires exactly the word.

What I need is that of "Go" if "Store" is inside the string.

What I need would be something like this in PHP but in HTML Example code:

if(strpos($useragent, "Store") !== false){
//Note this is a demo code of what I want to achieve but in HTML
}

The detail is that it is in HTML and I don't know how to do it.

I am editing a template extension ".tpl.php" of Live Helper Chat

The code is outside the PHP tags as if it were HTML.

CodePudding user response:

Try {{ou.user_agent.includes("Store") ? "Go" : "Nope"}}

  • Related