Jump to content
thirty bees forum

Question

Posted
0
 

Hellou, I need put regex ^.gold|Gold|GOLD. in product.tpl (thirtybees 1.0.8) and check if product name consist gold or Gold or GOLD. If product name consist in product name for example Anchor blue Gold then I need create product flag. Is there possible? I try it, but function is not working correctly.

{if (preg_match('^.*gold|gold|GOLD.*', {$product->name|escape:'html':'UTF-8'}))}
                <span class="new-box">
                        <span class="zlato-label">GOLD 24K</span>
            {elseif(preg_match('^.*rosegold|Rosegold|ROSEGOLD.*', {$product->name|escape:'html':'UTF-8'}))}
                <span class="new-box">
                        <span class="zlato-label">Rose GOLD 24K</span>
            {else}
                <span class="new-box">
                        <span class="new-label">Nothing</span>
            {/if}

 

2 answers to this question

Recommended Posts

  • 0
Posted

Regular expression is invalid, it should be enclosed in start/end delimiters, ie '/^*gold|gold|GOLD.*/' where / is a delimiter. Also, drop the escape:'html':'UTF-8' part.

It should look like this:

{if (preg_match('/^.*gold|gold|GOLD.*/', $product->name))}
...
{/if}

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...