The 5 Different Conditions <v:if> Can Test For - May 28, 2009
Because it is so useful, today we're going to do a refresher on how to use the <v:if> tag. The <v:if> tag is Vae's conditional tag which renders some content only if a certain condition is met. There are five different tests the <v:if> tag is capable of.
Here they are:
- path - This is likely the most common attribute you'll use. It tests whether or not a specific value is set.
Our address is: <v:text path="address" />
- param - This checks to see if a GET or POST parameter has been specified. For example if a page is listing search results, we could do something like:
Search Results for <v:text param="query" />
- total_items - Tests against the number of items in a Collection.
Add some thing else to your cart! Your fifth item is free.
- id - Tests against the ID of the current entry.
Please keep this item out of reach of small children.
- is - Checks the value of the path or param value.
<v:if path="location" is="New York">
We provide free shipping in New York!
Pretty cool eh? You can also place <v:else> tags within <v:if> blocks to tell Vae what to render if a condition doesn't exist.