Flexible Content nested Clone
-
Hey!
another little issue i am facing are nested cloned flexible content fields.
Let me clear that out:
I have a FC-Field called Page-Builder with Layouts and ACFE-Options setted up.
Page-Builder
– Hero Layout
– Content Layout
– Row Content
– …. and some more
– Grouped Layout which is a Clone of the current Flexible Content fieldIf i use the native template usage to render these fields it does what it should. But if i use the_flexible helper, nothing is rendered inside the clone field.
if( function_exists('acf_add_local_field_group') ): acf_add_local_field_group(array( 'key' => 'group_5d4a8ae8a5e2f', 'title' => 'Layouts', 'fields' => array( array( 'key' => 'field_5d4a8aeeba9bf', 'label' => 'PageBuilder', 'name' => 'pagebuilder', 'type' => 'flexible_content', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'acfe_permissions' => '', 'acfe_flexible_stylised_button' => 1, 'acfe_flexible_layouts_thumbnails' => 1, 'acfe_flexible_layouts_templates' => 1, 'acfe_flexible_layouts_previews' => 1, 'acfe_flexible_close_button' => 1, 'acfe_flexible_title_edition' => 0, 'acfe_flexible_copy_paste' => 1, 'acfe_flexible_modal_edition' => 0, 'acfe_flexible_modal' => array( 'acfe_flexible_modal_enabled' => '0', ), 'acfe_flexible_layouts_state' => '', 'layouts' => array( 'layout_5d4a8af774d8f' => array( 'key' => 'layout_5d4a8af774d8f', 'name' => 'hero', 'label' => 'Hero', 'display' => 'block', 'sub_fields' => array( array( 'key' => 'field_5d4a8b18ba9c0', 'label' => 'Image', 'name' => 'image', 'type' => 'image', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'acfe_permissions' => '', 'acfe_uploader' => 'wp', 'acfe_thumbnail' => 0, 'return_format' => 'id', 'preview_size' => 'thumbnail', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => '', ), array( 'key' => 'field_5ddb96fd0766a', 'label' => 'Text', 'name' => 'text', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'acfe_permissions' => '', 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', ), ), 'min' => '', 'max' => '', 'acfe_flexible_render_template' => 'layouts/hero/template.php', 'acfe_flexible_render_style' => '', 'acfe_flexible_render_script' => '', 'acfe_flexible_thumbnail' => '', ), 'layout_5ddb97080766b' => array( 'key' => 'layout_5ddb97080766b', 'name' => 'grouped', 'label' => 'Grouped', 'display' => 'block', 'sub_fields' => array( array( 'key' => 'field_5ddb97220766c', 'label' => 'Grouped Content', 'name' => 'grouped_content', 'type' => 'clone', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'acfe_permissions' => '', 'clone' => array( 0 => 'group_5d4a8ae8a5e2f', ), 'display' => 'seamless', 'layout' => 'block', 'prefix_label' => 0, 'prefix_name' => 1, 'acfe_clone_modal' => 0, ), ), 'min' => '', 'max' => '', 'acfe_flexible_render_template' => 'layouts/grouped/template.php', 'acfe_flexible_render_style' => '', 'acfe_flexible_render_script' => '', 'acfe_flexible_thumbnail' => '', ), ), 'button_label' => 'Layout hinzufügen', 'min' => '', 'max' => '', ), ), 'location' => array( array( array( 'param' => 'post_type', 'operator' => '==', 'value' => 'page', ), ), ), 'menu_order' => 0, 'position' => 'normal', 'style' => 'default', 'label_placement' => 'left', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => true, 'description' => '', 'acfe_display_title' => '', 'acfe_autosync' => '', 'acfe_permissions' => '', 'acfe_form' => 0, 'acfe_meta' => '', 'acfe_note' => '', )); endif;
And here the example to render these fields:
// This works if( have_rows('pagebuilder') ): ?> <h3>Native usage</h3> <?php while( have_rows('pagebuilder') ): the_row(); ?> <?php if( get_row_layout() == 'hero' ): ?> <div><?php the_sub_field( 'text' ); ?></div> <?php elseif( get_row_layout() == 'grouped' ): ?> <ul> <strong>Inside Group</strong> <?php while ( have_rows('grouped_content_pagebuilder') ): the_row(); ?> <?php if( get_row_layout() == 'hero' ): ?> <li><?php the_sub_field( 'text' ); ?></li> <?php endif; ?> <?php endwhile; ?> </ul> <?php endif; ?> <?php endwhile; ?> <hr> <?php endif; // ACFE-Way: didnt work if( has_flexible( 'pagebuilder' ) ): echo '<div>is inside pagebuilder</div>'; the_flexible( 'pagebuilder' ); endif;
I hope you understand my issues. If something is unclear, let me know! ??
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Flexible Content nested Clone’ is closed to new replies.