Get Help/Forums/Design Tips & Tricks

If {{ $productdescription }} Contains a String

shakespearesattic
posted this on August 14, 2011 19:37

Hi, Everyone!

I could spend hours trying to figure this out. But, I thought maybe someone will know this off the top of his/her head. I am comfortable with html, but not Velocity or Java.

I want to search for a string inside the product description and produce a result. I'll be using snippets.

For example:  Let's say I'm looking for the phrase "the cat is in the hat" in the product description, then I want to do one of the following:

If true, display "the cat is in the hat"
If false, display "the cat is not in the hat"

I've scanned the Velocity tutorial and googled java examples. It sure seems to me that there should be simple solution. Maybe I missed it. I should also probably add that I will be adding multiple nested if statements. So, my assumption is that I'll be using "else" if the condition is false.


Any help would be greatly appreciated. Thanks!

 

Comments

User photo
Tomas
Highwire Commerce

We're in the process of converting our existing templates to a new markup language called "Liquid". Liquid is a more commonly used markup language and contains a filter such as "contains". This can not be currently done with Velocity.

We should be supporting Liquid in the next week or so. Please keep an eye out in the announcements for more details in the next week or 2.

August 15, 2011 16:00
User photo
shakespearesattic

Thank you, Tomas.

August 15, 2011 19:07
User photo
stonehillcollectibles

Tomas, will this require any modifications to existing custom templates???

August 16, 2011 09:46
User photo
Tomas
Highwire Commerce

Existing templates using velocity will still be supported for the foreseeable future. :)

August 17, 2011 07:36