0

I am using below code to search string in given string in smarty but below code not working

$MyError = "Attribute";
{if $MyError|strpos:'Attribute Registration Number with value'} 
<p>Welcome</p>
{/if} 
Shreya
  • 61
  • 2
  • 5
  • 14

1 Answers1

2

In Smarty, you can use the PHP function strpos to search a string in given string :

{if strpos('Attribute Registration Number with value', $MyError) !== false}
  <p>Welcome</p>
{/if}

Here is an other post about it.

Exiam
  • 91
  • 6
  • How did you define your variable? If you want to define the variable directly in your template, you should use the {assign} tag like {assign var="MyError" value="Attribute"} (see more: http://www.smarty.net/docs/en/language.function.assign.tpl) – Exiam Jun 28 '17 at 19:13