Child Custom Elements

I have a custom element called “Slider”

I also have a custom element “Slider Item”

Slider has a “sortable” control set up to allow slider items to be inserted.

I have successfully created the admin fields so I can do that part.

My issue is getting the “child” items to build my slider html.

How can one access the data in child sortable items?

indent preformatted text by 4 spaces

cs_register_element( 'full-width-slider', array(
  'title' => __( 'Full Width Slider', 'your-text-domain' ),
  'values' => array(
    'text_content' => cs_value( ),
    'slides'=> cs_value( ),
  ),
	'control_nav' => array(
		'full-width-slider' => __( 'Slider', 'your-text-domain' ),
		'full-width-slider:setup' => __( 'Setup', 'your-text-domain' ),
		'full-width-slider:design' => __( 'Design', 'your-text-domain' ),
	),
  'control_groups' => array(
    'full-width-slider' => __( 'Full Width Slider', 'your-text-domain' ),
    'full-width-slider:setup' => __( 'Setup', 'your-text-domain' ),
    'full-width-slider:design' => __( 'Design', 'your-text-domain' ),
  ),
	'controls' => array(
		array(
			'type'=>'group',
			'label' => 'Setup',
			'group'=>'full-width-slider:setup',
			'controls'=>array(
				array(
					'type'=>'sortable',
					'key'=>'slider_items',
					'options' => array(
						'element' => 'slider-item',
						'title' => __( 'Item', 'g-extension' ),
						'floor'   => 1,
						'capacity' => 10,
						'child'=>true,
						'render_children'=>true,
					),
				),
			),
		),
	),
  'render' => 'my_element_render',

) );

function my_element_render( $data ) {

  extract( $data );
	echo '<pre>';var_dump($data);echo '</pre>';

  return 'content: '.$text_content;

}

Child element

cs_register_element( 'slider-item', array(

		'title' => __( 'Slider Item', 'your-text-domain' ),
		'child'=>true,
		'values'=>array(
			'slider_item_image'=>cs_value(),
			'slider_item_image_title'=>cs_value(),
		
		),
		'library'=>false,
		'controls'=>array(
			array(
				'key'=>'slider_item_image',
				'type'=>'image-source'
			),
			array(
				'key'=>'slider_item_image_title',
				'type'=>'text'
			),
		),
		'render' => 'slider_item_render',

	)
);

function slider_item_render($data){
	  extract( $data );
	//echo '<pre>';var_dump($data);echo '</pre>';
	
	$html = '';
	
	if($slider_item_image){
		$html .= '<img src="'.$slider_item_image.'" alt="'.$slider_item_image_title.'"/>';
	}
	
	return $html;
}

Hi @kire,

Thanks for reaching out.

Regretfully, providing custom code or enhancing custom code is outside the scope of our theme support. You may seek 3rd party developers to help you with your problems or you can avail One where we can answer questions outside of the features of our theme.

Hope that helps and thank you for understanding.

Hello Kiawah,

To better assist you with your issue, kindly provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role

To know how to create a secure note, please check this out: How The Forum Works

Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.