Support

Account

Forum Replies Created

  • sweet, however the issue is actually the_flexible_field(),
    get_row_layout() is not finding the layout. i have tried getting ‘repeat_content’ and ‘content_columns’ but neither is working

    <?php
    
        while(the_flexible_field('flexible_content')): 
          echo '<h2>flexi heading</h2>';
          switch (get_row_layout()):
    	 
    	  case 'repeat_content':
    	    echo '<h2>heading</h2>';
    		  if (function_exists('repeat_content')):
    		       content_columns();
    		    else:
    		      echo 'content col is not enabled';
    		  endif;
    	  break;
    	  case 'includes':
    		  if (function_exists('ml_acf_include')): 
    		      ml_acf_include();
    		    else:
    		      echo 'includes is not enabled';
    		    endif;
    	  break;
    	endswitch;
        endwhile; 
    

    heres the output of flexible_content

    Array
    (
        [ID] => 0
        [key] => field_flex_key
        [label] => flexible content
        [name] => flexible_content
        [prefix] => 
        [type] => flexible_content
        [value] => 
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => group_56ff5b11d1775
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => flexible_content
        [_input] => 
        [_valid] => 1
        [button_label] => Add Component
        [min] => 
        [max] => 
        [layouts] => Array
            (
                [0] => Array
                    (
                        [key] => layout_key
                        [name] => layouts
                        [label] => Components
                        [display] => block
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57032097d3ac0
                                        [label] => Content Columns
                                        [name] => content_columns
                                        [prefix] => 
                                        [type] => tab
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => content_columns
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [placement] => top
                                        [endpoint] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_repeatable_key
                                        [label] => Repeatable image with optional link
                                        [name] => repeat_content
                                        [prefix] => 
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => repeat_content
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [row_min] => 0
                                        [row_limit] => 
                                        [layout] => table
                                        [button_label] => Add Component
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 0
                                                        [key] => field_56a749bdc0553
                                                        [label] => Content Column
                                                        [name] => text_area
                                                        [prefix] => 
                                                        [type] => wysiwyg
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => field_repeatable_key
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => text_area
                                                        [_input] => 
                                                        [_valid] => 1
                                                        [default_value] => 
                                                        [tabs] => all
                                                        [toolbar] => full
                                                        [media_upload] => 1
                                                    )
    
                                            )
    
                                        [min] => 0
                                        [max] => 0
                                        [collapsed] => 
                                    )
    
                                [2] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_styling_tab
                                        [label] => Row Styling
                                        [name] => row_styling
                                        [prefix] => 
                                        [type] => tab
                                        [value] => 
                                        [menu_order] => 2
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => row_styling
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [placement] => top
                                        [endpoint] => 0
                                    )
    
                                [3] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_570320bbd3ac1
                                        [label] => row class
                                        [name] => row_class
                                        [prefix] => 
                                        [type] => text
                                        [value] => 
                                        [menu_order] => 3
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => row_class
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [default_value] => 
                                        [placeholder] => 
                                        [prepend] => 
                                        [append] => 
                                        [maxlength] => 
                                        [readonly] => 0
                                        [disabled] => 0
                                    )
    
                                [4] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031ca0179ba
                                        [label] => boxed content
                                        [name] => boxed_content
                                        [prefix] => 
                                        [type] => true_false
                                        [value] => 
                                        [menu_order] => 4
                                        [instructions] => the width of the content will be limited to the amount set in the stylesheet code.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => boxed_content
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [message] => 
                                        [default_value] => 1
                                    )
    
                                [5] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031c64179b9
                                        [label] => invert colors
                                        [name] => invert_colors
                                        [prefix] => 
                                        [type] => true_false
                                        [value] => 
                                        [menu_order] => 5
                                        [instructions] => dark color scheme for this panel instead of a light color scheme
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => invert_colors
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [message] => invert color scheme
                                        [default_value] => 0
                                    )
    
                                [6] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031b1b179b8
                                        [label] => style options
                                        [name] => style_options
                                        [prefix] => 
                                        [type] => select
                                        [value] => 
                                        [menu_order] => 6
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => style_options
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [choices] => Array
                                            (
                                                [None] => None
                                                [option 1] => option 1
                                                [option 2] => option 2
                                            )
    
                                        [default_value] => Array
                                            (
                                            )
    
                                        [allow_null] => 0
                                        [multiple] => 0
                                        [ui] => 0
                                        [ajax] => 0
                                        [placeholder] => 
                                        [disabled] => 0
                                        [readonly] => 0
                                    )
    
                                [7] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_57031afc179b7
                                        [label] => bg_image
                                        [name] => bg_image
                                        [prefix] => 
                                        [type] => image
                                        [value] => 
                                        [menu_order] => 7
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_flex_key
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => bg_image
                                        [_input] => 
                                        [_valid] => 1
                                        [parent_layout] => layout_key
                                        [return_format] => array
                                        [preview_size] => thumbnail
                                        [library] => all
                                        [min_width] => 
                                        [min_height] => 
                                        [min_size] => 
                                        [max_width] => 
                                        [max_height] => 
                                        [max_size] => 
                                        [mime_types] => 
                                    )
    
                            )
    
                        [min] => 
                        [max] => 
                    )
    
            )
    
    )
  • i realize the values are not outputting on the frontend. how would i output the value of

    acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_repeatable_key',
          )
        );

    (keep in mind this is a field within a repeater) on the frontend

  • thanks for your help. this is working now. it was related to another issue

    <?php if( function_exists('acf_add_local_field_group') ) {
      
        acf_add_local_field_group(
          array (
            'key' => 'group_56ff5b11d1775',
            'title' => 'add component',
            'fields' => array (
              array (
                'key' => 'field_flex_key',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
              'button_label' => 'Add Row',
              'min' => '',
              'max' => '',
              'layouts' => array (
                array (
                  'key' => 'layout_key',
                  'name' => 'sample_label',
                  'label' => 'sample label',
                  'display' => 'block',
                  'min' => '',
                  'max' => '',
                ),
              ),
              ),
            ),
            'location' => array (
              array (
                array (
                  'param' => 'post_type',
                  'operator' => '==',
                  'value' => 'post',
                ),
              ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
          )
        );
        
        acf_add_local_field(
          array (
    	'key' => 'field_57032097d3ac0',
    	'label' => 'Content Columns',
    	'name' => 'content_columns',
    	'type' => 'tab',
            'parent' => 'field_flex_key', //flex field key
            'parent_layout' => 'layout_key', // layout key
    	'instructions' => '',
    	'required' => 0,
    	'conditional_logic' => 0,
    	'wrapper' => array (
    		'width' => '',
    		'class' => '',
    		'id' => '',
    	),
    	'placement' => 'top',
    	'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
          array (
            'key' => 'field_repeatable_key',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'field_flex_key', //flex field key
            'parent_layout' => 'layout_key', // layout key
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          )
        );
        
        acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_repeatable_key',
          )
        );
    
        acf_add_local_field(
          array (
    	      'key' => 'field_styling_tab',
    	      'label' => 'Row Styling',
    	      'name' => 'row_styling',
    	      'type' => 'tab',
    	      'parent' => 'field_flex_key', //flex field key
    	      'parent_layout' => 'layout_key', // layout key
    	      'instructions' => '',
    	      'required' => 0,
    	      'conditional_logic' => 0,
    	      'wrapper' => array (
    		      'width' => '',
    		      'class' => '',
    		      'id' => '',
    	      ),
    	      'placement' => 'top',
    	      'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'parent' => 'field_flex_key', //flex field key
    			'parent_layout' => 'layout_key', // layout key
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		      )
    		);
      
      }
    
    ?>
  • that is not the issue. the row class needs to be outside of the repeater.

    here is what i am trying to replicate with tabs and ‘add local field group’

    <?php
    
    acf_add_local_field_group(array (
    	'key' => 'group_57031a424348c',
    	'title' => 'content_columns',
    	'fields' => array (
    		array (
    			'key' => 'field_57032097d3ac0',
    			'label' => 'Content Columns',
    			'name' => 'content_columns',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array (
    			'key' => 'field_57031a4b179b3',
    			'label' => 'content columns',
    			'name' => 'content_columns',
    			'type' => 'repeater',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'collapsed' => '',
    			'min' => '',
    			'max' => '',
    			'layout' => 'table',
    			'button_label' => 'Add Content Column',
    			'sub_fields' => array (
    				array (
    					  'key' => 'field_5704f37ef4e95',
    					  'label' => 'text_area',
    					  'name' => 'text_area',
    					  'type' => 'wysiwyg',
    					  'instructions' => '',
    					  'required' => 0,
    					  'conditional_logic' => 0,
    					  'wrapper' => array (
    						  'width' => '',
    						  'class' => '',
    						  'id' => '',
    					  ),
    					  'default_value' => '',
    					  'tabs' => 'all',
    					  'toolbar' => 'full',
    					  'media_upload' => 1,
    				),
    			),
    		),
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'Row Styling',
    			'name' => 'row_styling',
    			'type' => 'tab',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'placement' => 'top',
    			'endpoint' => 0,
    		),
    		array (
    			'key' => 'field_57031acc179b6',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		),
    	),
    	'location' => array (
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'post',
    			),
    		),
    		array (
    			array (
    				'param' => 'post_type',
    				'operator' => '==',
    				'value' => 'page',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'normal',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => 1,
    	'description' => '',
    ));
    
    ?>
    
  • awesome. that works. im now trying to solve it using tabs too. here im trying to break the fields into two tabs. havent figured it out yet though as the last tab has no fields attached to it.

    <?php if( function_exists('acf_add_local_field_group') ) {
      
        acf_add_local_field_group(
          array (
            'key' => 'group_56ff5b11d1775',
            'title' => 'add component',
            'fields' => array (
              array (
                'key' => 'field_56ff5b1a77c75',
                'label' => 'flexible content',
                'name' => 'flexible_content',
                'type' => 'flexible_content',
                'instructions' => '',
                'wrapper' => array (
                  'width' => '',
                  'class' => '',
                  'id' => '',
                ),
              'button_label' => 'Add Row',
              'min' => '',
              'max' => '',
              'layouts' => array (
                array (
                  'key' => '56ff5b1a77c76',
                  'name' => 'sample_label',
                  'label' => 'sample label',
                  'display' => 'block',
                  'min' => '',
                  'max' => '',
                ),
              ),
              ),
            ),
            'location' => array (
              array (
                array (
                  'param' => 'post_type',
                  'operator' => '==',
                  'value' => 'post',
                ),
              ),
            ),
            'menu_order' => 0,
            'position' => 'normal',
            'style' => 'default',
            'label_placement' => 'top',
            'instruction_placement' => 'label',
            'hide_on_screen' => '',
            'active' => 1,
            'description' => '',
          )
        );
        
        acf_add_local_field(
          array (
    	'key' => 'field_57032097d3ac0',
    	'label' => 'Content Columns',
    	'name' => 'content_columns',
    	'type' => 'tab',
            'parent' => 'field_56ff5b1a77c75', //flex field key
            'parent_layout' => '56ff5b1a77c76', // layout key
    	'instructions' => '',
    	'required' => 0,
    	'conditional_logic' => 0,
    	'wrapper' => array (
    		'width' => '',
    		'class' => '',
    		'id' => '',
    	),
    	'placement' => 'top',
    	'endpoint' => 0,
          )
        );
    
        acf_add_local_field(
          array (
            'key' => 'field_56ff5b1a77c79',
            'label' => 'Repeatable image with optional link',
            'name' => 'repeatable_imgs',
            'type' => 'repeater',
            'parent' => 'field_56ff5b1a77c75', //flex field key
            'parent_layout' => '56ff5b1a77c76', // layout key
            'row_min' => 0,
            'row_limit' => '',
            'layout' => 'table',
            'button_label' => 'Add image',
          )
        );
        
        acf_add_local_field(
          array (
          'key' => 'field_5237950f6c6e4',
          'label' => 'url',
          'name' => 'img_link_url',
          'type' => 'text',
          'parent' => 'field_56ff5b1a77c79',
          )
        );
    
        acf_add_local_field(
          array (
    	      'key' => 'field_570320bbd3ac1',
    	      'label' => 'Row Styling',
    	      'name' => 'row_styling',
    	      'type' => 'tab',
    	      'parent' => 'field_56ff5b1a77c75', //flex field key
    	      'parent_layout' => '56ff5b1a77c76', // layout key
    	      'instructions' => '',
    	      'required' => 0,
    	      'conditional_logic' => 0,
    	      'wrapper' => array (
    		      'width' => '',
    		      'class' => '',
    		      'id' => '',
    	      ),
    	      'placement' => 'top',
    	      'endpoint' => 1,
          )
        );
    
        acf_add_local_field(
    		array (
    			'key' => 'field_570320bbd3ac1',
    			'label' => 'row class',
    			'name' => 'row_class',
    			'type' => 'text',
    			'parent' => 'field_570320bbd3ac1', //flex field key
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array (
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    			'readonly' => 0,
    			'disabled' => 0,
    		      )
    		);
      
      }
    
    ?>
    
  • Thanks for your help with this. I’m still in struggled town and still haven’t managed to get it to work. I’m a bit confused by this part “extra setting called ‘parent_layout’ containing the string layout key” in particular the string layout key

  • here is the full output of flexible content. i guess i just cant do what i wanted as i have tried specifying the parent as ‘subfields’ i also tried ‘field_subfields’ and neither worked. Its a real shame that we can import simple single fields into other simple field structures but cant do the same with flexible content.

    the reason i am trying to do this is I want to manage and reuse parts of flexible content arrays more effectively. Are there any other methods you would suggest?

    Array
    (
        [ID] => 0
        [key] => field_subfields
        [label] => flexible content
        [name] => flexible_content
        [prefix] => 
        [type] => flexible_content
        [value] => 
        [menu_order] => 0
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => group_56ff5b11d1775
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => flexible_content
        [_input] => 
        [_valid] => 1
        [button_label] => Add Row
        [min] => 
        [max] => 
        [layouts] => Array
            (
                [0] => Array
                    (
                        [key] => subfields
                        [name] => sample_label
                        [label] => sample label
                        [display] => block
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 0
                                        [key] => field_to_import
                                        [label] => Repeatable image with optional link
                                        [name] => repeatable_imgs
                                        [prefix] => 
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => field_subfields
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => repeatable_imgs
                                        [_input] => 
                                        [_valid] => 1
                                        [row_min] => 0
                                        [row_limit] => 
                                        [layout] => table
                                        [button_label] => Add image
                                        [parent_layout] => subfields
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 0
                                                        [key] => field_5237950f6c6e4
                                                        [label] => url
                                                        [name] => img_link_url
                                                        [prefix] => 
                                                        [type] => text
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => leave blank if link is not required
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => field_to_import
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => img_link_url
                                                        [_input] => 
                                                        [_valid] => 1
                                                        [formatting] => html
                                                        [default_value] => 
                                                        [maxlength] => 
                                                        [placeholder] => 
                                                        [prepend] => 
                                                        [append] => 
                                                        [readonly] => 0
                                                        [disabled] => 0
                                                    )
    
                                            )
    
                                        [min] => 0
                                        [max] => 0
                                    )
    
                            )
    
                        [min] => 
                        [max] => 
                    )
    
            )
    
    )
    
Viewing 9 posts - 1 through 9 (of 9 total)