samrap/acf-fluent

->shortcodes() can not be used with an array

Log1x opened this issue · 2 comments

Log1x commented

With the introduction of Group fields, my template is getting pretty heavy with values being inside of the group's array.

I was curious if you thought about any fluent, elegant way we could retrieve values, as well as process their shortcodes without assigning it to a variable and running do_shortcode() on it?

At the moment, I have to do the following:

$header = Acf::field('header')->get();
return do_shortcode($header['subtitle']);

It'd be pretty nice to be able to retrieve a specific keys value from the array and process our escapes, shortcodes, and possibly even a default right from the ->get()-go.

Something like Acf::field('header')->key('subtitle')->shortcodes()->get() ?

I'm sure it can be done in a much more sane syntax, the above is merely a pseudo-example.

Also, have you brainstormed on how we could have_rows(); the_row(); using acf-fluent? It'd be absolutely great if I can ditch ACF's functions all together. They are just... ugly. I ignore them in most cases using Blade directives with Sage 9, but I'd still much rather using acf-fluent for all of my ACF calls.

I'm sure you've thought about the above and it might just not be deemed sane-- but I thought I'd bring it up nonetheless.

Thanks a lot for acf-fluent. Using it with acf-builder is really great. 😃

Hey! Sorry for the late response, I never saw the notification.

I'm currently working on an elegant solution for group/clone fields. No code just yet, trying to see if it even makes sense from a usability and performance standpoint. As it is, ACF Fluent instantiates 2 classes for every call. My main priority is bringing that down at the moment, but I definitely would like an elegant solution to group fields as well.

As far as an implementation of have_rows(); the_row();, I have decided not to support these functions. I avoid the loop like the plague in WordPress, and those functions can easily be replaced with something like the following (Sage 9/ACF Flex template):

@while (the_flexible_field('modules'))
    @include('modules/'.get_row_layout())
@endwhile

This avoids the need to use those nasty loop functions in the first place. I have not come across another need for them since. If you have a use case, feel free to let me know and I'll consider implementing something. I have a couple more functions coming shortly in 0.4 😁 .

Sorry again for seeing this so late, and thanks for the support! Stoked that other people are finding this thing fun to use!

Closing this issue for now. I will leave it open for discussion.