Speak to our experts today 0333 004 0333
Speak to one of our experts today
User Guides

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
Equals
This is used to test whether two values are equal to one another. You can test strings, integers and EKM Tag outputs.

[ekm:if]
 iftype='EQUALS';
 ifvalue='100';
 ifvalue2='100';
 ifthen='They are equal';
 ifelse='Nope, not equal';
[/ekm:if]
								
Plain Text Logic
If 100 is Equal to 100 then output They are equal otherwise output Nope, not equal
This would return True and would output...
They are equal
Contains
This used to test whether a string contains another string.

[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]
								
Plain Text Logic
If the string 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.
This would return True and would output...
It contains this!
Greater Than
This is used to test whether the first value is greater than the second value. You can test only integers and EKM Tag outputs.

[ekm:if]
 iftype='GREATERTHAN';
 ifvalue='123';
 ifvalue2='321';
 ifthen='It's greater';
 ifelse='It's less';
[/ekm:if]
								
Plain Text Logic
If 123 is Greater than 321 then output It's greater otherwise output It's less
This would return False and would output...
It's less
Less Than
This is used to test whether the first value is less than the second value. You can test only integers and EKM Tag outputs.

[ekm:if]
 iftype='LESSTHAN';
 ifvalue='123';
 ifvalue2='321';
 ifthen='It's less';
 ifelse='It's greater';
[/ekm:if]
								
Plain Text Logic
If 123 is Less than 321 then output It's greater otherwise output It's less
This would return True and would output...
It's less
IN
This is used to test whether the first value is equal to any of the comma delimited values in the second value. You can test strings, integers and EKM Tag outputs. Useful when used with the [ekm:categoryid] tag.
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]
								
Plain Text Logic
If 52 is In the list 4, 8, 15, 16, 23, 42 then output In here otherwise output Not here
This would return False and would output...
Not here
Web Page
This tag is used to test whether or not a webpage exsists on your EKM and whether or not it is active. Useful when used with the [ekm:webpagename] tag

[ekm:if]
 iftype='WEBPAGE';
 webpageid='1';
 ifvalue='TRUE';
 ifthen='Exists';
 ifelse='Does Not Exist';
[/ekm:if]
								
Plain Text Logic
If webpage 1 does Exist then output Exists otherwise output Does Not Exist
This would return True and would output...
Exists
Has Sub Categories
This is used to check whether a category, specified by ID, has sub-categories within it.

[ekm:if]
 iftype='HAS_SUB_CATEGORIES';
 ifvalue='52';
 ifthen='Has Sub Cats';
 ifelse='No Sub Cats';
[/ekm:if]
								
Plain Text Logic
If category 52 has sub-categories then output Has Sub Cats otherwise output No Sub Cats
This would return False and would output...
No Sub Cats
Is Element Not Empty
This is used to check whether an element, specified by 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]
								
Plain Text Logic
If element welcome-area has Content then output Has Content otherwise output Does Not Have Content
This would return True and would output...
Has Content
Is The Page Currently Selected
This is used to determine whether or not you are current on the category, product or webpage specified by ID. This is useful if you wish your category menu to display an indication that you are currently on this page.

[ekm:if]
 iftype='IS_SELECTED';
 ifvalue='CATEGORY(52)';
 ifthen='You are here';
 ifelse='You are not here';
[/ekm:if]
								
Plain Text Logic
If category 52 is currently selected then output You Are Here otherwise output You are not here
This would return True and would output...
Has Content
Product Type
This statement is used to test whether you are on a specific platform. This means you can test whether your account is set to EKM or ekmSitebuilder (plus the variations of sitebuilder), this allows you to display different content.

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]
								
Plain Text Logic
If your account's PRODUCT type is currently EKMPOWERSHOP then output You have an EKM otherwise output You have an ekmSitebuilder Account
This would return True and would output...
You

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)

Shop Owner Logged In
This statement is used to test whether or not you are logged into your EKM or not. This allows shop owners to display code, messages or images to internal users of the shop meaning their customers (customers of the shop) will ever see them.

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]
								
Plain Text Logic
If you are the shop owner and LOGGEDIN then output Shop Owner Is Logged Into Their Shop otherwise output The Shop Owner Is Not Logged In
If you are a shop owner this would return True and would output...
Shop Owner Is Logged Into Their Shop
Product Has Reviews
This statement is used to check whether a product, defined by an ID, has customer reviews or not.

[ekm:if]
  iftype='HAS_REVIEWS';
 ifvalue='1';
 ifthen='Has reviews';
 ifelse='Doesn't have reviews';
[/ekm:if]
								
Has Feature Installed
This statement is used to check whether a system feature is installed on the shop.

[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

Is Mobile Browser
This statement is used to check whether the device being used is a mobile browser or not. If the page is loaded on a mobile device but the desktop version of the page is requested it will return 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.

Nesting This Tag

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.

Hiding Prices Within Specific Categories

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]
								
Hiding Prices When £0.00

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]
								
Displaying A Stock Message

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]
								
Displaying A Stock Message in Stages

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]