DMXzone App Connect Support Product Page


How do I show an element only if a database date field doesn't have the value '0000-00-00'?

Asked 23 Apr 2018 14:33:56
has this question
23 Apr 2018 14:33:56 Bruce Wilkie posted:
Hi there

I'm wanting to show an element only if a database date field has a value entered

If there is no value then the field has the value: 0000-00-00

Here's the code from my page that's not working. Can you let me know what it should read?

<span dmx-show="{{fixturedate2}} <> '0000-00-00'">Show this content</span>

(note, this is in a repeat already and is showing other bindings in the same repeat area ok - I couldn't insert the whole code as support system was blocking me)

thanks in advance


Replied 23 Apr 2018 15:19:19
23 Apr 2018 15:19:19 Teodor Kuduschiev replied:
Hi Bruce,
The right syntax for doing this is:
<span dmx-show="fixturedate2 != '0000-00-00'">Show this content</span>
depending on what the database field type is you may or may not need the single quotes ' ' arround the 0000-00-00.
Replied 24 Apr 2018 09:51:30
24 Apr 2018 09:51:30 Bruce Wilkie replied:
Hi Teodor

Unfortunately that's not working, but I've found a workaround.

When I try the code:

<span dmx-show="{{fixturedate2}} != '0000-00-00'"> - {{fixturedate2.formatDate("dd MMM"}}</span>

Note that fixturedate2 has the value '0000-00-00' as it's a date field and hasn't had a value assigned to it.
In the above example the span is shown on screen, with ' - 01 Jan' in it.

So i tried the oposite with dmx-hide and it worked using the following:

<span dmx-hide="{{fixturedate2}} = '0000-00-00'"> - {{fixturedate2.formatDate("dd MMM"}}</span>

In this case the span stays hidden.

Happy that I found the workaround, but would still like to get to the bottom of why dmx-show isn't working as intended.

With this extra info, are you able to provide any ideas on this?

Replied 24 Apr 2018 09:54:14
24 Apr 2018 09:54:14 Bruce Wilkie replied:

Sorry, my workaround didn't work after all.
In the second example above, when using dmx-hide I thought it worked, but now it never shows the span no matter what value is in fixturedate2

Please help me find out the problem and fix it?

Replied 24 Apr 2018 10:06:30
24 Apr 2018 10:06:30 Teodor Kuduschiev replied:
Hi Bruce,
It is not really clear what are you doing, your explanations are really confusing?

Note my code - it doesn't have {{ }} in the condition ... make sure you use the exact code i provided.
Replied 24 Apr 2018 12:02:35
24 Apr 2018 12:02:35 Bruce Wilkie replied:
Hi Teodor

I tried taking the brackets off as follows:

<span dmx-hide="fixturedate2 = '0000-00-00'"> - {{fixturedate2.formatDate("dd MMM"}}</span>

The result of this was that the span didn't display, no matter what the value of fixturedate2

In addition, all other dynamic data taken from the database, that was previously visible now doesn't display either. Most of the page content is now missing.

Any ideas what I'm donig wrong?
Replied 24 Apr 2018 12:07:04
24 Apr 2018 12:07:04 Bruce Wilkie replied:
OK, fixed that last problem. Used '==' instead of '=' and that seems to have got it all working properly now.

thanks Teodor
Appreciate your help as always


Reply to this topic