The "great" Miva forum banned me for registering and asking this question. Not sure if any here can help me with this...
On the category pages, I need to display the products in columns based on Best Sellers, New Releases, etc. There are categories set up with subcategories. Products are assigned to a category and possibly a subcategory.
Choral
- Choral Best Sellers
- Choral New Releases
Vocal
- Vocal Best Sellers
- Vocal New Releases
All parent categories' names are one word, with their subcategories adding two words. The category page will show all the products in the parent category, I just want to filter what's in each in column. I was trying to compare the added two words to part of the subcategory name with an expression. That way it wouldn't matter what parent category you were in, the same code could be used for all. Seems like something that's very basic, but isn't working.
Example non-working code:
<div class="row">
<h2>Best Sellers</h2>
<mvt:foreach iterator="product" array="products">
<mvt:if expr="'Best '$'Sellers' IN g.category:name">
product display stuff here
</mvt:if>
</mvt:foreach>
</div>
<div class="row">
<h2>New Releases</h2>
<mvt:foreach iterator="product" array="products">
<mvt:if expr="'New '$'Releases' IN g.category:name">
product display stuff here
</mvt:if>
</mvt:foreach>
</div>
If you haven't already, you might want to pick up the PCI Net Tool Belt. It's written by Ray Yates, and very well documented. It is a Miva Merchant Language Extension module, which will give you wonderful access to Miva Merchant that SMT won't (by default).
The issue that you're running into is that you're looking at a variable which doesn't exist. Your "scope" is off. The variable
g.category_codeholds the category code in the Global variable context (which is what I think you may be confusingg.category:namewith). You need to look in the LOCAL variable context.Your
<mvt:foreach>looks fine.Try changing your code from:
To:
Or even:
That way you won't have to do the unnecessary concatenation. ;)