Using v:if total_items to determine no items
  • Is there a way to use v:if total_items in a collection to determine either 0 or <=1, >=1 etc ?

    This works:
    <v:if total_items="1"><li>One item</li></v:if>

    But this does not:
    <v:if total_items="0"><li>Zero items</li></v:if>

    It would also be nice if you could use operators within total_items.

  • 3 Answers sorted by
  • you can go up one context and do

    <v:if path="items">greater than zero items</v:if>
    <v:else>zero items</v:else>

  • COUNT() is special in VaeQL.

    You can do:

    <v:if path="COUNT(items)>1">

  • total_items is bogus, and the other answers won't work for complex v:collection scenarios. Use this:

    <v:collection path="widgets[whatever=whatever]" filter="whatever" counter="index">
    yadda yadda
    </v:collection>
    <v:if path="$index"></v:if><v:else>No matches found</v:else>

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion