Jump to content
  • 0

Krótszy zapis warunków w smarty


hakeryk2

Question

Witam,

 

Mam pewien problem, troszkę leniwy ale nie mogę znaleźć szybko rozwiązania, a może ktoś potem w Google odnajdzie ten temat. Jak krócej zapisać w Smarty taki warunek?

{if
    $product->id|intval == 1478
    OR $product->id|intval == 2063
    OR $product->id|intval == 3608
    OR $product->id|intval == 3511
    OR $product->id|intval == 5644
    OR $product->id|intval == 5655
    OR $product->id|intval == 5656
    OR $product->id|intval == 5665
    OR $product->id|intval == 5678
} kod do egzekucji {/if}

Lub taki 

{if
	in_array(140,Product::getProductCategories($product->id|intval))
	OR in_array(33,Product::getProductCategories($product->id|intval))
	OR in_array(34,Product::getProductCategories($product->id|intval))
	OR in_array(35,Product::getProductCategories($product->id|intval))
}
	Jakiś kod tutaj
{/if}

Jak wyeliminować powtórzenia?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

spróbuj tak:

{assign var=tablica value=array(1,5,6,8,22,66,77) }

{if  in_array(5, $tablica)}
    <h1> jakiś kod 1</h1>

{/if}


{assign var=tablica2 value=array(5, 99, 22) }
{if  array_intersect($tablica2, $tablica)}
    <h1> jakiś kod 2</h1>

{/if}

  • Like 1
Link to comment
Share on other sites

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...