AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
877 stars 182 forks source link

WP All Import #766

Open firstinternet opened 2 years ago

firstinternet commented 2 years ago

Hello,

We're currently using Gutenberg blocks & ACF which works great, however, I need to import some content into these blocks and I'm stumbled across a bit of an issue.

I'm using WP All Import to import the .XML file and within the content I've created 2 ACF Blocks, like so:

<!-- wp:acf/title \{
"id":"block_6357c910facb3",
"name":"acf/title",
"data":\{
"page_title":"{title[1]}",
"_page_title":"field_63299e5627967",
"overline_title":"",
"_overline_title":"field_63299ec327969",
"page_title_color":"gradient",
"_page_title_color":"field_63299efa2796b",
"background_color":"white",
"_background_color":"field_63356786e30b4",
"override_spacing_top":"0",
"_override_spacing_top":"field_63456f35e1d6f"
\},
"align":"",
"mode":
"edit"
\} /-->

<!-- wp:acf/text \{
"id":"block_637f5dc0aa693",
"name":"acf/text",
"data":\{
"field_6329d5982c9a3":"{content[1]}",
"field_634fb2b975920":"standard",
"field_637df5fd86866":"navy",
"field_6329d5c2c7bb5":"100",
"field_63456e46ba04e":"white",
"field_634d1b970f43b":"0",
"field_63456f35e1d6f":"0",
"field_635a5d2a75b63":"0",
"field_63775e03eb024":"0",
"field_63775e07eb025":"0"
\},
"align":"",
"mode":"edit"
\} /-->

The first block works perfectly, however, the second does not import.

Do I need to do anything differently?

CreativeDive commented 2 years ago

hey @firstinternet,

please read about this here: https://github.com/AdvancedCustomFields/acf/issues/729, it could be related to your issue. Do you have tried to use the second (not working) block like in the scheme of the first block?

Make sure the block pattern data contains the field name and the second underscore key like:

<!-- wp:acf/block_name {"name":"acf/block_name","data":{
    "field_name_1":"0", "_field_name_1":"field_61a74f4183569",
    "field_name_6":"0","_field_name_6":"field_62ebd50507f0a",
    "field_name_10":"none","_field_name_10":"field_61adeeb4073cd"
},"mode":"preview"} -->

I'm pretty sure this is the reason your block isn't working. Now it remains to find out how this block pattern code was inserted?

firstinternet commented 2 years ago

Thanks for the reply @CreativeDive.

I've tried to following:

<!-- wp:acf/text \{
"id":"block_637e0c9f82056",
"name":"acf/text",
"data":\{
"text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam eu turpis molestie, dictum est a, mattis tellus. Sed dignissim, metus nec fringilla accumsan, risus sem sollicitudin lacus, ut interdum tellus elit sed risus. Maecenas eget condimentum velit, sit amet feugiat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent auctor purus luctus enim egestas, ac scelerisque ante pulvinar. Donec ut rhoncus ex. Suspendisse ac rhoncus nisl, eu tempor urna. Curabitur vel bibendum lorem. Morbi convallis convallis diam sit amet lacinia.\r\n\r\nCurabitur tempor quis eros tempus lacinia. Nam bibendum pellentesque quam a convallis. Sed ut vulputate nisi. Integer in felis sed leo vestibulum venenatis. Suspendisse quis arcu sem. Aenean feugiat ex eu vestibulum vestibulum. Morbi a eleifend magna. Nam metus lacus, porttitor eu mauris a, blandit ultrices nibh. Mauris sit amet magna non ligula vestibulum eleifend. Nulla varius volutpat turpis sed lacinia. Nam eget mi in purus lobortis eleifend. Sed nec ante dictum sem condimentum ullamcorper quis venenatis nisi. Proin vitae facilisis nisi, ac posuere leo.",
"_text":"field_6329d5982c9a3",
"text_size":"standard",
"_text_size":"field_634fb2b975920",
\},
"align":"",
"mode":"edit"
\} /-->

Once imported in the editor I get the following:

Screenshot 2022-11-24 at 16 04 10

When I switch to visual editor the block shows, however, no data is set.

CreativeDive commented 2 years ago

@firstinternet I wonder where the backslashes come from?

<!-- wp:acf/text \{ <--

or

"data":\{ <--

Is it the pattern code result what you get from after the import? How looks the pattern from the original content?

Have you tried to remove all backslashes and copy and paste the block pattern in the editor directly?

CreativeDive commented 2 years ago

@firstinternet In your last example pattern code:

"_text_size":"field_634fb2b975920",

There's a comma too many. The last entry should end without a comma in my opinion.

firstinternet commented 2 years ago

@firstinternet I wonder where the backslashes come from?

<!-- wp:acf/text \{ <--

or

"data":\{ <--

Is it the pattern code result what you get from after the import? How looks the pattern from the original content?

Have you tried to remove all backslashes and copy and paste the block pattern in the editor directly?

This is the format that I need to use when importing using WP ALL Import.

CreativeDive commented 2 years ago

If pasting the block pattern code works without backslashes but not with them, you have the reason. Did you try?

CreativeDive commented 2 years ago

Yep, I have tested it, backslashes not working in the pattern code.

firstinternet commented 2 years ago

Yep, I have tested it, backslashes not working in the pattern code.

Is this when using WP All Import?