Smack Digital Inc.

Common Smarty Statements For X-Cart Development

Posted by and last updated Jan 21, 2014 05:14 PM

The below Smarty statements are commonly used when modifying your X-Cart template (.tpl) files.

Home Page

{if $main eq "catalog" AND $current_category.categoryid ne ""}
I am on the home page.

Any Category

{if $main eq "catalog" AND $current_category.categoryid gt 0}
I am on a category listing page.

Specific Category (replace X with the numeric categoryid)

{if $current_category.categoryid eq X}
I am on category X.

Any Product

{if $main eq "product"}
I am on the product details page.

Specific Product (replace X with the numeric productid)

{if $product.productid eq X}
I am on product X.

Any Static Page

{if $main eq "pages"}
I am on a static page.

Specific Static Page (replace X with the numeric pageid)

{if $page_data.pageid eq X}
I am on page X.

Manufacturer Listing

{if $main eq "manufacturers"}
I am on the manufacturers listing page.

Any Manufacturer

{if $main eq "manufacturer"}
I am on the page of a specific manufacturer.

Specific Manufacturer Page (replace X with the numeric manufacturerid)

{if $manufacturer.manufacturerid eq X}
I am on manufacturer X.

Shopping Cart

{if $main eq "cart" OR $main eq "checkout" OR $main eq "order_message"}
I am in the checkout process.

Checkout Process

{if $main eq "checkout" OR $smarty.get.mode eq "checkout" OR $main eq "order_message" OR $smarty.get.mode eq "order_message"}
I am in the checkout process.

Anywhere Except Checkout

{if $main ne "cart" AND $main ne "checkout" AND $smarty.get.mode ne "checkout" AND $main ne "order_message" AND $smarty.get.mode ne "order_message"}
I am in not in the checkout process.

Only If Logged In

{if $login ne ""}
The user is logged in.

Only If Logged Out

{if $login eq ""}
The user is logged out.

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.

Browse By Category

RSS Feeds

Don't miss out! Subscribe to our RSS Feeds to receive instant notification when new entries are added.

RSS Feed for All Categories
RSS Feed for X-Cart Code Snippets
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us