EKM Tag: [ekm:if]
The IF tag is used to test whether or not a specific logic is true or false. It has many uses and can be used to test a number of things. There are a number of EKM Tags that can be nested within the IF, these will be noted within the "Nesting This Tag" section of each tag's documentation.
This is an advanced tag and should be avoided if you do not have an understanding of logic statements.
- Tag Information
- Nesting This Tag
- Examples
[ekm:if]
iftype='EQUALS';
ifvalue='100';
ifvalue2='100';
ifthen='They are equal';
ifelse='Nope, not equal';
[/ekm:if]
100
is Equal
to 100
then output They are equal
otherwise output Nope, not equal
True
and would output...
[ekm:if]
iftype='CONTAINS';
ifvalue='EKM - Your own easy to use online shop';
ifvalue2='online';
ifthen='It contains this!';
ifelse='Nope, doesn't contain this.';
[/ekm:if]
online
is within the string EKM - Your own easy to use online shop
then output It contains this!
otherwise output Nope, doesn't contain this.
True
and would output...
[ekm:if]
iftype='GREATERTHAN';
ifvalue='123';
ifvalue2='321';
ifthen='It's greater';
ifelse='It's less';
[/ekm:if]
123
is Greater
than 321
then output It's greater
otherwise output It's less
False
and would output...
[ekm:if]
iftype='LESSTHAN';
ifvalue='123';
ifvalue2='321';
ifthen='It's less';
ifelse='It's greater';
[/ekm:if]
123
is Less
than 321
then output It's greater
otherwise output It's less
True
and would output...Use this tag to check whether a value is found within a list.
[ekm:if]
iftype='IN';
ifvalue='John';
ifvalue2='David, Duane, Scott, Ben, Ash, Jonny, Matt';
ifthen='In here';
ifelse='Not here';
[/ekm:if]
52
is In
the list 4, 8, 15, 16, 23, 42
then output In here
otherwise output Not here
False
and would output...
[ekm:if]
iftype='WEBPAGE';
webpageid='1';
ifvalue='TRUE';
ifthen='Exists';
ifelse='Does Not Exist';
[/ekm:if]
1
does Exist
then output Exists
otherwise output Does Not Exist
True
and would output...
[ekm:if]
iftype='HAS_SUB_CATEGORIES';
ifvalue='52';
ifthen='Has Sub Cats';
ifelse='No Sub Cats';
[/ekm:if]
52
has sub-categories
then output Has Sub Cats
otherwise output No Sub Cats
False
and would output...element_reference
, has any content. This will always return true
if you are logged into the shop.
[ekm:if]
iftype='ELEMENT_NOT_EMPTY';
ifvalue='welcome-area';
ifthen='Has Content';
ifelse='Does Not Have Content';
[/ekm:if]
welcome-area
has Content
then output Has Content
otherwise output Does Not Have Content
True
and would output...
[ekm:if]
iftype='IS_SELECTED';
ifvalue='CATEGORY(52)';
ifthen='You are here';
ifelse='You are not here';
[/ekm:if]
52
is currently selected
then output You Are Here
otherwise output You are not here
True
and would output...This is typically used on custom designs and templates where the account owner may upgrade to EKM from ekmSitebuilder.
[ekm:if]
iftype='PRODUCT';
ifvalue='EKMPOWERSHOP';
ifthen='You have an EKM shop';
ifelse='You have an ekmSitebuilder Account';
[/ekm:if]
PRODUCT
type is currently EKMPOWERSHOP
then output You have an EKM
otherwise output You have an ekmSitebuilder Account
True
and would output...You can test against a number of different products and variations for a more specific output.
EKMPOWERSHOP - Test against an EKM account type
EKMSITEBUILDER - Test against an ekmSitebuilder account type (either in ekmSitebuilder or ekmSitebuilder with Catalogue feature)
EKMSITEBUILDER_WITHOUT_CATALOGUE - Test against an ekmSitebuilder account type but only when the Catalogue feature is not enabled.
EKMSITEBUILDER_WITH_CATALOGUE - Test against an ekmSitebuilder account type but only when the Catalogue feature is enabled.
EKMPOWERSHOP_OR_EKMSITEBUILDER_WITH_CATALOGUE - Test against an EKM account type or ekmSitebuilder (with Catalogue)
This is typically used by the template design team to display the template toolbox on some EKM templates.
Please note this determines whether the shop owner is logged in, not customers of the shop. If you wish to test whether shop customers are logged in you can use the
ekm:customer_logged_in
tag
[ekm:if]
iftype='LOGGEDIN';
ifthen='Shop Owner Is Logged Into Their Shop';
ifelse='The Shop Owner Is Not Logged In';
[/ekm:if]
LOGGEDIN
then output Shop Owner Is Logged Into Their Shop
otherwise output The Shop Owner Is Not Logged In
True
and would output...
[ekm:if]
iftype='HAS_REVIEWS';
ifvalue='1';
ifthen='Has reviews';
ifelse='Doesn't have reviews';
[/ekm:if]
[ekm:if]
iftype='FEATURE_ACTIVE';
ifvalue='VIEWSHOP-CUSTOMERREVIEWS';
ifthen='Is installed';
ifelse='Not installed';
[/ekm:if]
You can test against a number of different feature IDs to see whether they are installed or not.
VIEWSHOP-CUSTOMERREVIEWS - Customer reviews
VIEWSHOP-PRODUCTSHORTDESCRIPTION - Product short description
FEATURE-CUSTOMERLOGIN - Customer login
FEATURE-PRODUCTATTRIBUTES - Product attributes
ifelse
.
[ekm:if]
iftype='IS_MOBILE_BROWSER';
ifthen='Is a mobile browser';
ifelse='Is a desktop browser, tablet or the desktop version was requested.';
[/ekm:if]
The EKM system allows for some tags to be nested within other tags.
When nesting this tag need to prepend the open and close tags with nested_
and change all single quotes '
to double quotes "
[ekm:showdata]
...
output_item='<li class="
[ekm:nested_if]
iftype="IS_SELECTED";
ifvalue="CATEGORY([id])";
ifthen="selected";
ifelse="";
[/ekm:nested_if]
">[name]</li>';
...
[/ekm:showdata]
There are many uses for the [ekm:if]
tag, here are some example of common uses. These are advanced uses to achieve a specific goal but can be tweaked to fit your purpose.
You may want to hide prices for all products when you are within a specific category. This can be useful if products within these categories do not have prices or require telephone order. This example hides prices from a showdata
when you in category 52 or 8, and any sub-categories of these.
[ekm:showdata]
data='products';
location='auto';
output_item='
<section class="item i-[counter]">
<div class="item-image">[image]</div>
<header class="item-name">[name]</header>
[ekm:nested_if]
iftype="IN";
ifvalue="[ekm:categoryid]depth='0';[/ekm:categoryid]";
ifvalue2="52, 8";
ifthen="<div class="item-price">Call For Price</div>";
ifelse="
<div class="item-price">[price]</div>
<div class="item-rrp">[rrp]</div>
";
[/ekm:nested_if]
</section><!-- .item -->
';
[/ekm:showdata]
In some cases you may want to offer some products for free, for which you would set your price to £0.00 but this may not look as nice as text reading Free or perhaps an image. You can use this IF to hide the price when it is set to £0.00 or display text in the prices place.
[ekm:showdata]
data='products';
location='auto';
output_item='
<section class="item i-[counter]">
<div class="item-image">[image]</div>
<header class="item-name">[name]</header>
[ekm:nested_if]
iftype="EQUALS";
ifvalue="[price]";
ifvalue2="[ekm:currency_symbol][/ekm:currency_symbol]0.00";
ifthen="<div class="item-price">Free</div>";
ifelse="
<div class="item-price">[price]</div>
<div class="item-rrp">[rrp]</div>
";
[/ekm:nested_if]
</section><!-- .item -->
';
[/ekm:showdata]
When outputting products on the category page you may wish to output the stock level. Currently the stock
attribute tag will only output a number so it is important you specify your own message. This can be done using an if tag to check when the stock is lower than 1 (e.g. out of stock) and then display a message.
[ekm:showdata]
data='products';
location='auto';
output_item='
<section class="item i-[counter]">
<div class="item-image">[image]</div>
<header class="item-name">[name]</header>
[ekm:nested_if]
iftype="LESSTHAN";
ifvalue="[stock]";
ifvalue2="1";
ifthen="<div class="item-stock">Out Of Stock</div>";
ifelse="<div class="item-stock">In Stock</div>";
[/ekm:nested_if]
</section><!-- .item -->
';
[/ekm:showdata]
You may want to output a message that is defined by a number of stages. For example you may want to display "Out Of Stock" when stock is 0, "Low Stock" when less than 10 and "Good Stock" when 10 or greater. This can be achieved like the example below.
The reason this tag has an IF nested within another is because there is a problem with the logic when having 3 seperate tags. If the stock is 0 it will display "Low Stock" and "Out Of Stock" because the value is both less than one and less than 10. So by testing whether the stock is less than 1 and if not checking if its lower than 10 you prevent this issue.
You will also notice that the GREATERTHAN
if is checking whether the stock is greater than 9. This is because we want to check whether it is equal or greater than 10.
[ekm:showdata]
data='products';
location='auto';
output_item='
<section class="item i-[counter]">
<div class="item-image">[image]</div>
<header class="item-name">[name]</header>
[ekm:nested_if]
iftype="LESSTHAN";
ifvalue="[stock]";
ifvalue2="1";
ifthen="<div class="item-stock">Out Of Stock</div>";
ifelse="
[ekm:nested_nested_if]
iftype=(LESSTHAN);
ifvalue=([stock]);
ifvalue2=(10);
ifthen=(<div class="item-stock">Low Stock</div>);
ifelse=();
[/ekm:nested_nested_if]
";
[/ekm:nested_if]
[ekm:nested_if]
iftype="GREATERTHAN";
ifvalue="[stock]";
ifvalue2="9";
ifthen="<div class="item-stock">Good Stock</div>";
ifelse="";
[/ekm:nested_if]
</section><!-- .item -->
';
[/ekm:showdata]