Support

Account

Home Forums Feature Requests Import PHP for further use in UI tool

Solving

Import PHP for further use in UI tool

  • Hi all …

    I am looking for a solution to close a gap in my development chain of tools and processes. Basically I want to use the ACF generated PHP export and (re-)import it into ACF to be able to use the GUI tools to work on the groups and fields and then export it again.

    Why does ACF not support by default? This seems so natural to me. Experimenting with layouts is so much easier in the GUI than throwing array structures around.

    Would converting single groups to JSON and importing this work? Did I miss documentation?

    Best

    Wolfgang

  • There is nothing built into ACF that will let you import php code. You need to manually get the field group, convert it to JSON and then save it to a file.

    
    // create field group in php
    
    $group = acf_get_field_group('group_key');
    $group['fields'] = acf_get_fields('group_key');
    $json = json_encode($group);
    
    // save the json to a file http://php.net/manual/en/function.file-put-contents.php
    // there are other ways to do this as well
    
    

    When I’m converting a field group to PHP I generally also export a JSON version so that if I need to I can import it to make changes.

    The only reason I use PHP is if I want to make everything available for translation or I am going to do things that the ACF UI is incapable of doing, like building a dynamic field group that changes based on the page that’s being edited. If I am not worried about any of these conditions then I export the group as JSON and I add a load point to make ACF load the JSON files.

  • Hi John, I really would appreciate a tool integrated into ACF which would import the PHP it generates. Sometimes the workflow makes changes to the PHP necessary and more convenient and we need to reflect the changes back into the GUI.

    Since the PHP is one big file containing actual function calls to acf_add_local_field_group the reverse process would be easier if the PHP export was changed in a way so that including that export won’t be such a hassle due to the function calls.

    Asked differently: How can we assure a versioned workflow with both GUI tool and PHP export if we don’t get changes to the PHP easily back into the GUI tool (which happens to live on a different machine, btw.) I’ve tried that with JSON but the synching was confusing somehow and also doing strange things when switching between branches which I can‘t line out precisely right now.

    The reason we use the PHP is that I develop locally and the actual website is used by many editors and admin which should not fiddle with the field groups. So the ACF GUI on live is empty but changes made to the code on different developer machines should be able to integrated back into the dedicated building environments GUI.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Import PHP for further use in UI tool’ is closed to new replies.