2

I'm using the Tally add-on to display a total from a custom field I have that stores numeric values. It's working great, my only problem is that I need a conditional setup that will display 'your current total is 0' or even just '0' when the logged in user has a null or zero tally total.

When a logged in user visits my front-end template, it works perfectly if they have tally but if the tally is null or zero then it's completely blank. Does anyone know how to setup a conditional like this for Tally? I couldn't find any examples of conditionals for Tally in the documentation and I tried the code below to no avail:

{if tally:total == ""}You current total is 0.{/if}

The code above just displays every time whether or not the logged in user has a tally or not and I've tried it both with nothing in the quotes and with a zero in the quotes. I would greatly appreciate any tips or suggestions for accomplishing this, Thanks!

1
  • You are using this in an embedded template as per the docs yes? Mar 12 '17 at 2:02
3

Looking at that plugin's code, it should work fine if you're using a tag pair, and its {tally_total} variable, e.g.:

{exp:tally:total}
    {if ! tally_total}Your current total is 0.{/if}
{/exp:tally:total}
1

I contacted the plugin author about this issue and he gave me the following code:

{if '{exp:tally:total collection="hours"}' < 1}Your current total is 0.{/if}

This works perfectly and does exactly what I need. Thanks!

0

I'm not familiar with Tally but I wonder if the NOT operator could be your friend.

Something like:

{if ! tally:total}You current total is 0.{/if}
1
  • 1
    Thank you for the reply and suggestion. Unfortunately that's not working and generates a parse error. Mar 10 '17 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.