ACF Repeater Date condition

Hi there,

Im working on a layout (with Pro 4.2 beta_2) for an Events CPT and am using a repeater for dates and additionall Info. Output works like a charm but conditions on the consumer seems not to work properly:

Since I only want to show future Dates I set Conditions of the text-element (consumer) to date and put in:

{{dc:acf:sub_field field="date"}} after {{dc:global:date}}

But the first date (after today) always returns twice. I also checked “before” and this would work without issue.

Cheers
Patrik

Hi Patrik,

Thanks for letting us about this. I’ll try to reproduce it and let you know if I can find out what’s going on.

1 Like

Hi @alexander,
I can imagine you’ve got your hands full at the time. Just wanted to ask if there is any news on this.

Hi @BuzzStory,

I’m sorry about the delay here! I tested this and it’s working but I suspect there could be an issue depending on what return format you use on the ACF field. The dates are passed into the PHP strtotime function which guesses if you are using American/European formats. Here’s how they handle it (copied from PHP docs)

Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash ( / ), then the American m/d/y is assumed; whereas if the separator is a dash ( - ) or a dot ( . ), then the European d-m-y format is assumed. If, however, the year is given in a two digit format and the separator is a dash ( - ), the date string is parsed as y-m-d .

If you need to keep the return format the same, Dynamic Content has some low level parameters that let you reformat the output. If you set type="date", the result will be parsed using the date format configured with WordPress.

{{dc:acf:post_field field="date" type="date"}}

And if you already have type="date" you can also override the format used:

{{dc:acf:post_field field="date" type="date" format=""}}

These two parameters don’t really care if the data came from ACF or some other source, so even though it’s an ACF date field they can be used to reformat the value returned from ACF.

Thanks a lot for for taking the time @alexander!

I’m sorry but I really don’t know whats going on there. I’ve tried various ways to define type and format on the field itself and on global date but the issue remains. I even tried to use numbers condition as well and that also outputs the first matching date twice.
That’s one of my attempts to get as precise as possible, using acf datetime instead of date only:

Field {{dc:looper:field key=“tao_date” type=“date” format=“YmdHi”}}
Global: {{dc:global:date format=“YmdHi”}}

Date condition:

Number Condition:

hi,

can i chime in and ask something?
i still don’t understand what all can be used with dynamic content. what are the additions like date and format? is there a complete documentation about it? where can i learn more about it?

thanks in advance

Hi @BuzzStory,

Can you try adding a text element with both dynamic content tags you’re using? Something like:

{{dc:looper:field key=“tao_date” type=“date” format=“YmdHi”}}<br/>
{{dc:global:date format=“YmdHi”}}

Maybe seeing the exact output inline will provide a clue to why they’re not comparing properly. Thanks!

@deranaloge I’m sorry we don’t have an extensive reference on the subject. There’s an introductory article here: https://theme.co/docs/dynamic-content Let me know if you have any questions about it.

Thanks for your reply, @alexander,

Sure, I did that before to check format and values. Here’s the output:

Hi @BuzzStory,

Thanks! Looks ok. strtotime should be able to parse that just fine. I just tried that out myself and it’s working. I’m sorry we’ve not been able to narrow it down any further yet. Would it be possible for me to login and take a closer look? Thanks!

Thanks a lot @alexander,
Of corurse. Please find the credentials in the secure note. I really hope it‘s not just one stupid little thing I‘m overlooking here, since it costs you so much time.

Thanks you so much! I was able to recreate your setup locally and confirmed this is a bug. It’s been fixed for the next release. At the moment 4.2.2 is still quite stable and I’m not sure we’d do another point release just to fix this issue. If anything else comes up that’s more pressing and requires a release we’ll get it out.

Meanwhile, would you like me to install a development build of Pro that includes this fix and a few other minor tweaks? That would let you keep working in case we don’t have publicly available until a beta later in the month.

Awesome news, @alexander. Thank you very much!

If it’s no worries I’d very much appreciate a development build, since I’ll have a meeting with the guys I’m building the site for end of the week.
I’ll attach the ftp-credentials in a secure note in case you need them

Cheers!

Thanks! Ok, you’re all set. When the next update shows up on automatic updates you can safely update to that e version and these changes will be included.

Can’t thank you enough, @alexander. Thats awesome!

You’re most welcome! We ended up getting another release out after all yesterday after a few more things came up.

1 Like

Hey,

I think I’m currently having the same issue @BuzzStory had with the date format.

So I’ve been able to set a {{dc:looper:field key="modified"}} looper item and its displaying correctly as its shown on the debug.consumer . Here is how it looks below:

But I’m now trying to get the modified date to be displayed in a more compact way of just Month and Year, so I’ve tried using this dynamic content field {{dc:looper:field key="modified" format="F j, Y"}} but it not giving me the formatted result:

I’ve also done it like @alexander suggested also which looks like this:


But it seems to be ignoring the formating parse. This is an ACF Repeater as well. Current Pro version installed is 4.2.3.

Any idea if this could just be on my end or something related to a bug?

Might just be me not doing it right as well, which is quite likely haha!

What you have in that last screenshot where type is included should work. It might be the curly quotes throwing things off. Give this one a try:

{{dc:looper:field key="modified" type="date" format="YmdHi"}}

Amazing @alexander, it was the curly lines in the end haha! Thanks for that, really amazing that we can dig out all of this information from each file and display it.

Ok great! Glad to hear that. ACF is such a great plugin for managing information and it has been really cool watching people build designs around it now that we’ve tied everything together with Dynamic Content and Loopers.