PDA

View Full Version : Finding array item count


kipm8va
08-09-06, 01:03 AM
How can i find the item count for an array? On the Category Product List page, when the Category list only contains subcategories, there is no product image to display until a subcategory is selected. In that case, the customer would like to display an image to fill the empty area. How can I check the array count in the template to display an alternate image when there is no product, just a subcategory?

Thank you in advance.

Bruce - PhosphorMedia
08-09-06, 04:58 AM
While in a foreach iterator loop, the variable 'pos1' should be the count...however, the code you want is:


<mvt:if expr="l.settings:product_count EQ 0">


which is already in place the Category Product List Layout section, just replace this code:


<mvt:if expr="l.settings:product_count EQ 0">
<mvt:exit />
</mvt:if>

with

<mvt:if expr="l.settings:product_count EQ 0">
<img src="image you want shown">
<mvt:exit />
</mvt:if>



For example, you could use: l.settings:category_title:image to display the parent cat's title image...just be sure to change the code on the CTGY main template to remove the "IF Cat Title Image" show Cat Title Image, else show Name, to just show the name.