[Resolved] Generateblocks and ACF

Home Forums Support Generateblocks and ACF

  • This topic has 11 replies, 4 voices, and was last updated 2 months ago by Tom.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1170117
    Marcel

    First of all, I want to congratulate you on the launch of the Generateblocks plugin, the whole community has been looking forward to this. I’m sure it will be very successful.
    However, I would like to ask you, if I could integrate some custom fields, made with ACF Pro plugin, into the blocks made with Generateblocks. Unfortunately, using shortcodes only works for simple text-based values. I would need all kind of values, not just text.
    I would be very happy if there was any such integration, otherwise, I would have to use the ACF blocks, but it would be more work, in the sense of customization from a visual point of view.
    Thank you and wish you much success with Generateblocks!

    #1171042
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    What kind of integration are you looking for, exactly? What would those custom fields output? In which of our blocks?

    I appreciate the feedback! πŸ™‚

    #1175049
    Marcel

    The idea would be to get the values added on ACF fields and place them on the Generateblocks’ blocks. It is something similar to how Elementor uses ACF fields values. This kind of integration I was looking for, but it seems to be complicated.

    Now I can use the ACF Blocks feature to achieve this.

    #1629763
    Sam

    Here’s an example I’m currently trying to figure out.

    I have two custom fields the client can edit:

      phone_number_dialer (text)
      phone_number_display (text)

    Ideally, I can use a GB Headline block set to Paragraph, and edit the HTML to do this:

    <a href='tel:[acf field="phone_number_dialer"]'>[acf field="phone_number_display"]</a>

    When I try that now, the GB block converts my single quotes for the href into double and converts the double-quotes inside the brackets into &quot;. Escaping them inside brackets doesn’t seem to work.

    #1630528
    David
    Staff
    Customer Support

    Hi Sam,

    you can create your own shortcode that returns the HTML and the ACF Fields. Here’s an example from ACF Support:

    https://support.advancedcustomfields.com/forums/topic/displaying-fields-html-in-functions-php/

    #1630802
    Sam

    That did the trick! Thanks, David.

    #1630850
    David
    Staff
    Customer Support
    #1631644
    Tom
    Lead Developer
    Lead Developer

    This seems like it would be useful when coupled with something like our Elements module, but not too useful otherwise. Am I right?

    In the next version of GP Premium, we’re adding dynamic fields to GenerateBlocks inside our Block Elements.

    #1631767
    Sam

    That was my intent, but I think it’s useful anywhere site-wide data is needed.

    For example, I created Site Header and Footer blocks (Elements), and wanted them to display the client’s contact details (phone, email, region) across the site.

    My mistake was adding custom fields (with ACF) to the Elements themselves and expecting them to be displayed throughout the site. (Post ID’s/queries would be different from the Element posts, so the custom field data wouldn’t be available anywhere else. Lesson learned.)

    After more reading, I discovered ACF options pages, and created one for the contact details. Then, with David’s helpful link, I created a shortcode to query and return data from the options page, and placed that shortcode in my site header and footer Elements.

    It’s kind of hacked together, but accomplishes what I wanted: one central place for my non-tech savvy client to update their contact information so it’s automatically updated site-wide. Now the site header, site footer, and their Contact page are automatically updated without them touching page or Element/block content directly.

    Super glad to hear this is coming to GPP!

    #1631926
    Tom
    Lead Developer
    Lead Developer

    Ah yes, the next version of GPP will make this much easier! We’re almost ready for public testing πŸ™‚

    #1653574
    Samuel

    Will there be a link for public testing? I have a project where I created several shortcodes to get around this kind of issue. Would love to solve this in GP/GB without additional shortcodes.

    #1653690
    Tom
    Lead Developer
    Lead Developer

    Yes, once available you’ll be able to download it in your account, or opt-in for updates via your Dashboard: https://docs.generatepress.com/article/beta-testing/

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.