0

I'm having a bear of a time with what I thought would be a simple conditional. I've got a Low Variables Matrix field with several dates and custom messages. Basically the client wants to use these dates to remove their phone number on holidays and have a custom message like "Closed today - Merry Christmas!."

Here's what I'm using for testing:

{exp:low_variables:pair var='lv_holiday_message' search:date='04/08/16'}
{if '{total_rows}' == '1'}
 {holiday_message}
    {if:else}
    TEST
    {/if}
{/exp:low_variables:pair}

The first conditional always works - if one of the date columns matches the search date then my custom message gets shown. But I can't for the life of me figure out what conditional shows something when a date DOESN'T match. I've tried if:else's , total rows == 0 or empty, checking for data on just the date column itself, if no_results and it never return a my TEST text.

Am I missing something simple or is this just not possible?

2 Answers 2

0

Can you elaborate more? If the date matches it shows {holiday_message}. Its correct. But if the date doesn't match does it shows holiday_message ?? I mean to say whatever be the date does it shows the holiday_message. It means it always goes in first if. If that is the case you can try below -

{exp:low_variables:pair var='lv_holiday_message' search:date='04/08/16'}
   {if total_rows == '1'}
       {holiday_message}
   {if:else}
       TEST
   {/if}
{/exp:low_variables:pair}

If this doesn't work you can try using -

{if total_rows == 1}

Hope this helps you.

1
  • Like my original post said, I tried total_rows, no_results, etc... but nothing worked. Sent a message directly to Pixel and Tonic and they sent me an updated copy of Matrix that allowed the {if no_results} tag to work again. There was a small bug in the version I had. Commented Apr 21, 2016 at 17:11
0

Turns out there was a small bug in Matrix causing the {if no_results} tag to stop parsing. Pixel and Tonic got me an updated version (2.6.2) and that allowed me to use the tag correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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