Hi Rik! Hope you're well :) long time no speak.
I'm trying to create a site for events where the colour of the icon is different depending on how many days there are before the event starts. I've got a date field with the 'time ago' formatter - the result shows '2 days' (for example). I was trying to do a global:php field to take the number out of that string and just use that, but having no luck (also, if it's less than 1 day, it changes to hours, rather than 'Today') - i gathered from other support threads you can't use a date field itself as a differentiator.
I'm probably going about it totally the wrong way - I tried to re-watch your presentation on youtube for using global:math but the quality doesn't let you make out any of the text on screen (and I'm not sure it would exactly solve my issue)
Please let me know if you have any ideas...
Best,
D.
Comments
Comment #1
rdeboerHey D,
Good to hear from you. Hope all's well?
From memory, the result of the expression you decide to use needs to be just a number, so "2", not "2 days"....
Is there another formatter/expression you can use.... Like seconds past (divided by 24*60*60 to get days).
If you have no luck, I may have some time this weekend to see what can be done...
Rik
Comment #2
Funksmaname commentedOK - my problem seems to be with the global:math field now.
I'm getting two fields - one for todays date in seconds and the other for the event in seconds.
event = 1384286400
today = 1384081200
If i do the math in a calculator manually I get the correct result - but if I use any tokens in the math field something odd happens:
[event] = 0, so [event] - [today] = [today]
any idea what might be happening!?
Comment #3
rdeboerSo you're saying the moment you put the [event] and [today] tokens in the Global:math expression, the [event] token returns zero, while the [today] token works?
Does [event] by itself returns the correct value?
Comment #4
Funksmaname commentedcorrect, i have all 3 displaying so the result is:
1384286400
1384167600
0
where the 0 is the provided token for line 1 - if I change that to the token for line two it works and shows '134167600'... line one is a date field, line two is a php field with todays date as 'U'.
Comment #5
rdeboerDanny, mate,
Maybe next weekend... I'm snowed-under...
Rik
Comment #6
Funksmaname commentedno worries mate! I should post this oddness under the global:math field issue queue :) Good luck with your work!
Comment #7
rdeboerJust wondering -- did you make sure to arrange the order of the fields in the View so that fields that the Global:math field relies on come ABOVE the Global:math field?
Rik
Comment #8
rdeboerClosing due to lack of activity.
Please open with an update, if you have one.
Rik