Support

Account

Home Forums General Issues $block > [margin] returns string(21) “var:preset|spacing|80”

Solving

$block > [margin] returns string(21) “var:preset|spacing|80”

  • This is with the Gutenberg plugin installed the new feature allows presets for Margins.
    [“spacing”]=> array(1) { [“margin”]=> array(2) { [“top”]=> string(21) “var:preset|spacing|80” [“bottom”]=> string(21) “var:preset|spacing|80”

    The margin currently returns a string that is 21 characters and in a fun format. I can make a filter or check the variable for just numbers and so on. My question isn’t how I can get what I need from the string…

    My question is, is this going to be changing once that preset goes live for Gutenberg to all websites and does ACF have a better way of handling it in the pipeline?

    I do have ACF Pro.
    I am using Blocks so it returns the $block variable.
    This is specifically found when block.json has

    "supports": {
       "spacing": {
          "margin": true
       }
    }

    So the margin is set to True and you obtain this margin by calling
    $block['style']['spacing']['margin']['bottom']

    Which is another question in itself, are there any plans to change this array location in the future? I can ask another topic about this.

  • This reply has been marked as private.
  • Hello, I am also wondering the best approach to using these new spacing presets with ACF blocks. Does anyone have a solution?

  • Agreed that the status of this would be great to know. There are workarounds to this output of course but it doesn’t seem ideal, and I wouldn’t want future updates to break those workarounds…

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

You must be logged in to reply to this topic.