Hi, is there a way to access ACF group fields in the looper current item ? Without creating another imbricated looper.
Thanks.
Hi, is there a way to access ACF group fields in the looper current item ? Without creating another imbricated looper.
Thanks.
Hello @popoche,
Thanks for writing in! The ACF group Fields will return an array which is why it is really necessary to run another looper to display those fields.
Best Regards.
Hope this makes sense.
Thanks for the reply !
I understand but creating a new looper just to access a variable in acf group field in a element, prevents to access the parent looper in the children of the element.
I think a notation like {{dc:looper:field key=“key_of_the_array.member_of_the_array”}} would be preferable
I have looked in the code to understand how it works and I noted that the function cs_get_path is able to access member of an array if you use the fields keys
(exemple : {{dc:looper:field key=“field_61bd7f503926b.field_61bd7f573926c”}})
But even if it returns the correct value of the member array (in an Options fields group), it’s not displayed in the live page. I don’t know why.
Thanks.
Hi @popoche,
To investigate it more, can you please provide login credentials for your site in a secure note to examine it further, including:
– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific Page URL where you have used this Dynamic Content
To create a secure note, click the key icon underneath any of your posts.
Thanks
Thanks for the reply but it’s not an issue with my site, it’s about accessing ACF group field with DC.
You think an ACF group is the same thing as a ACF repeater with one element. It’s not, otherwise the Group would have no reason to exist.
The purpose of the Group is to display some variables together and to have a clearer UI. But the current state of the dynamic content doesn’t allow me to use Groups in the back-office for my client.
An ACF group is equivalent to a PHP array with non-numeric keys, consequently members should be accessible as easily with {{dc:looper:field key=“sizes.thumbnail”}}
Can you get a dev to review this ? Thank you very much.
Hey @popoche,
You can check the thread below explaining how you can access the ACF Group fields.
Please let us know if that’s what you wanted.
Thank you.
Thank for both your answers but you are two both missing the point. I’ll try to explain again.
I know how ACF groups and ThemeCo Dynamic Content work, I use them on a semi-regular basis and I’m beyond the “how-to-use-them” level. I now have reach the limits of what is possible or not and have found a feature that I think is missing.
Even if ThemeCo Dynamic Content treats them at the same thing, let me explain one more time the fundamental difference between ACF Groups and Repeaters :
a group has one-and-only-one instance. All of its members are known beforehand by name and should be accessible directly. There is no need for a looper here.
a repeater can have 0, 1 or many instances, depending of the user in the back-office. It’s true dynamic content and the use of a looper is perfectly logic here.
After some research of the possibilities, I realised the only way to use groups with dynamic content was to create a new looper provider and I concluded that solution was not appropriate because you should not have to “stack” a new looper (masking the parent looper so messing your dynamic structure) just to access a group, created only for the sake of (UI) organization.
I have recreated a simplified version of my project, just to explain what you suggested was not a practical solution.
In a schematic view, my client can setup any number of slides, put an image and a text in each slide, and decide the layout (either to put the image above or on the side of the text, and makes the image container bigger or smaller than the text container)
Here is the ACF structure without groups. Note it’s only an example and the real project has tens of variables and repeaters items take more than one screen in height.
Here is the outline of the project.
The slider has the looper provider. The slide has the looper consumer. The image and the text use the dynamic content of the slide repeater.
To control the slide layout, I use classes on the slide item, using dynamic content.
With CSS, I can easily then change the direction of the flex wrapper or change the grow of the image or text container.
All works well, until I feel the need to make the UI more clear, because as previously stated, each slide repeater item was taking more than one screen height and could be confusing for a lambda user.
Now, after putting the variables in a single group, it’s not possible anymore to access them via Dynamic Content. It’s a bad solution to have to create a new looper for the group, because every children in the hiearchy cannot access anymore the variables of the parent looper (the slide).
To resume:
in ACF, a group is cosmetic. It aggregates some variables in the back-office UI. In PHP, you can retrieve them as an array, but it’s the same as getting each value by name. Everything is static, there is only one array and members names are known beforehand.
using a looper provider to access a group is a work-around solution that may not work in some cases, where stacking a new looper on top of a main one what is still needed, will not work.
it should be possible to access an ACF group member via dynamic content as easily as if it was an array. DC already manages it for arrays (see the documentation https://theme.co/docs/acf-pro-and-loopers) : {{dc:looper:field key=“sizes.thumbnail”}}
Consider this as a feature request:
It would be nice to be able to access “ACF group” members also via the dot notation. Creating a new looper for that is restrictive. The function cs_get_path already does this kind of job. It seems technically feasible, and reasonable.
Thanks for taking the time to read my post.
Hey @popoche,
I’ll post this case in our internal tracker as a feature request so that way, it will be queued to be checked by our development team.
Thank you for your feedback.
Thank you very much
Hi @popoche,
You’re welcome! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.
Thank you.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.