- Theme Engine
- Design Principles
- Templates
- EVML Reference
- Output
- Comments
- Operators
- Statements and Declarations
- Built-in Functions
- Built-in Objects
- Account
- Address
- Array
- Boolean
- Branch
- Cart
- CartLine
- Category
- CategoryCollection
- CategoryFilter
- CategoryFilterCollection
- CategoryFilterOption
- CategorySearch
- Collection
- Color
- Contact
- Currency
- Date
- Discount
- Dom
- Event
- EventCollection
- EventSlot
- Image
- Layout
- Locale
- Money
- Number
- Object
- Page
- PageCollection
- PageSearch
- PageSharer
- Pagination
- Postage
- Price
- PriceDiscount
- Product
- ProductCollection
- ProductCustomisation
- ProductDownload
- ProductMedia
- ProductMediaFrame
- ProductPrice
- ProductSearch
- ProductSpecification
- ProductSpecificationValue
- ProductVariation
- ProductVariationOption
- RecentlyViewed
- RegExp
- Request
- Review
- ReviewCollection
- Search
- SearchCollection
- SearchResult
- String
- Tag
- Template
- Url
- Website
- EV Tags
- CSS Pre-processor
- Ajax API
if...else
The if statement executes a block of code if a specified condition is true. If the condition is false, another statement can be executed.
Syntax
<?ev
// example 1
if (condition) {
code block executed if condition is true
}
// example 2
if (condition) {
code block executed if condition is true
} else {
code block executed if condition is false
}
// example 3
if (condition1) {
code block executed if condition1 is true
} else if (condition2) {
code block executed if condition1 is false and condition2 is true
} else {
code block executed if condition1 is false and condition2 is false
}
?>
Note EVML requires curly brackets ({...}) code block execution even for single statements.
Example
Usually we want to wrap HTML in a conditional statment
<?ev if (website.isCommerce) { ?>
You have an e-commerce website
<?ev } else if (website.isCatalogue) { ?>
You have a product catalogue
<?ev } else { ?>
Yours is a CMS website
<?ev } ?>