Quick collections of X-Cart if/else or “if/then” statements maybe useful in the future as reference.
there is no if/then in x-cart 😉
Very simple ideas:
What if I want something like this:
if cat=1 [html1]
if cat=2 [html2]
else [html3]
{if $cat == 1} -- do this -- {elseif $cat == 2} -- do this -- {else} -- if neither is true do this -- {/if} Very nice post on tweaking x-cart: common if/then modifications to x-cart
Targeting a whole Sub-Category with one if statement
Home Page
{if $main eq “catalog” AND $current_category.categoryid ne “”}
{/if}
{if $main eq "catalog" and $cat eq ""}
- main page, home.php
{else}
- not main page, home.php
{/if}
Any Category
I am on a category listing page.
{/if}
Specific Category (replace X with the numeric categoryid)
I am on category X.
{/if}
Any Product
I am on the product details page.
{/if}
Specific Product (replace X with the numeric productid)
I am on product X.
{/if}
Any Static Page
I am on a static page.
{/if}
Specific Static Page (replace X with the numeric pageid)
I am on page X.
{/if}
Manufacturer Listing
I am on the manufacturers listing page.
{/if}
Any Manufacturer
I am on the page of a specific manufacturer.
{/if}
Specific Manufacturer Page (replace X with the numeric manufacturerid)
I am on manufacturer X.
{/if}
I am in the checkout process.
{/if}
Checkout Process
I am in the checkout process.
{/if}
Anywhere Except Checkout
I am in not in the checkout process.
{/if}
Only If Logged In
The user is logged in.
{/if}
Only If Logged Out
The user is logged out.
{/if}
Sources:
{if} {else} statement tweaking
If statement with multiple categories
if / else code to show one block of content on home page
if/else for header.tpl to display different header on …
{if $cat eq “264” or $cat eq “271” or $cat eq “275”}
Code
{else}
Code
{/if}
{if $cat ne “31542”}
code
{/if}
{if $cat eq “31549” or $cat eq “31550” or $cat eq “31552” or $cat eq “31644” or $cat eq “31553” or $cat eq “31551”}
code
{/if}
**}
<div style=”text-align:center;”>
<!– above left menu links from module –>
<br>{{if $cat == 31682 || 31683 || 31795 ||31841}}
{{if $cat eq “31682” or $cat eq “31683” or $cat eq “31795” or $cat eq “31841” or $cat eq “31841” or $cat eq “31841”}}
{if $cat eq “31683” or $cat eq “31822” or $cat eq “31830” or $cat eq “31682” or $cat eq “36425”}
{else}
<br>
{include file=”customer/flyout-xcart.tpl”}
{/if}
{***
{if $main eq “catalog” || $main eq “search” || $main eq “pages”}
{include file=”customer/social-media.tpl”}
{/if}
***}