I’m creating a custom elementor module with a repeater in it, and for each repeater element I need to select a ready-made template from the created loop items. How to do this?
<?php
namespace elementorWidget;
use ElementorControls_Manager;
use ElementorWidget_Base;
class CustomStore extends Widget_Base
{
public function get_name()
{
return 'custom_store';
}
public function get_title()
{
return __('Custom Store', 'custom-store');
}
public function get_categories()
{
return ['general'];
}
/**
* Register widget controls.
*/
protected function _register_controls()
{
$this->start_controls_section(
'section_content',
[
'label' => esc_html__('Content', 'textdomain'),
'tab' => ElementorControls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'store_settings',
[
'label' => esc_html__('Store Settings', 'textdomain'),
'type' => ElementorControls_Manager::REPEATER,
'fields' => [
[
'name' => 'title_section',
'label' => __('Title for Section', 'custom-store'),
'type' => ElementorControls_Manager::TEXT,
'placeholder' => __('Enter Title', 'custom-store'),
'default' => __('Default Title', 'custom-store'),
],
],
]
);
$this->end_controls_section();
}
protected function render()
{
$settings = $this->get_settings();
$args = [];
show_template('template', $args, str_replace(get_stylesheet_directory() . DIRECTORY_SEPARATOR, '', __DIR__));
}
}
I tried to put it in a selector, but it doesn’t work as it should. Maybe there is some special field for this or something else.