Support

Account

Home Forums Add-ons Flexible Content Field Modify flexible content block options on the fly

Helping

Modify flexible content block options on the fly

    • hughc

    • May 22, 2019 at 5:46 pm

    Hi,
    I’ve developed a pretty straightforward row / column pseudo page builder, that I’d like to use site-wide. I’ve got a set of ‘column types’, each a field group that is set to ‘inactive’, that I then display as clones to populate the add-a-column popup in each row. All good

    I now want to add some custom post type specific blocks to the popup, but only when the user is editing a post of that CPT.

    I’ve read the docs, and I can’t see a way to vary the options shown on the add popup, depending on the context the Flexible Content field is being edited.

    Any ideas?
    cheers,
    Hugh

  • Is it sub fields in a layout that you want to add or do you want you want to add additional layouts.

    If it is the latter, adding layouts, this would be done better by removing layouts. You would create these layouts and they would be part of the flex field. Then you would create an acf/load_field filter, loop over the layouts and keep them or remove them based on what is being edited. I posted an extremely basic example of doing this here https://support.advancedcustomfields.com/forums/topic/disable-layout-from-showing-in-template/

    Adding additional fields would be more problematic. In this case you’d need to add these fields using PHP https://www.advancedcustomfields.com/resources/register-fields-via-php/. Although, you could probably use the same removal method as above but you’d need to loop over all of the fields in each layout as well and remove them.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.