Elementor: Feature Request: Advanced Shortcode Widget with Dynamic Parameters

Created on 20 Apr 2018  路  3Comments  路  Source: elementor/elementor

I had encountered a limitation to the "single" page templates.

Basically, i have a shortcode that receive a parameter and output some html accordingly.

I would like to be able to have an Advanced Shortcode Widget where you could specify the name of the shortcode and each parameter required while being able to feed some parameters with dynamic content.

Let's take this tag for example:

[output_youtube_video title=sometitle youtubeid=somevalue]

Where sometitle & somevalue comes from the queried element

componendynamic-tag typdeveloper-api

Most helpful comment

@bainternet I'm an Elementor Newbie and I would like to re-use the "Products" widgets with parameters.

I would love to define a Products template and then alter the content by adding parameters to the shortcode. This way I could reuse styles while being able to change the content displayed

Something like this
[elementor-template id="7972" taxonomy="product_cat" terms="high-uv-buff" taxonomy2="product_tag" terms2="blue"]
So basically take the template and display Woocommerce products that fit the category High UV Buff庐 and the tag "blue"

Similar stuff I would like to do with the Posts Widget

Is this already possible or is this a feature request?

All 3 comments

@chemocool

In this case, you should Wrap your shortcode in an Elementor widget and use controls with the dynamic as active.

for example:

```PHP
/**

  • Elementor #4181
    *
  • Elementor widget utilizes dynamic tags
    *
  • @since 1.0.0
    */
    class Custom_Widget_Issue_4181 extends \Elementor\Widget_Base {
public function get_name() {
    return 'output_youtube_video';
}


public function get_title() {
    return __( 'Custom Youtube', 'plugin-name' );
}


public function get_icon() {
    return 'eicon-youtube';
}

public function get_categories() {
    return [ 'general' ];
}

/**
 * Register oEmbed widget controls.
 *
 * Adds different input fields to allow the user to change and customize the widget settings.
 */
protected function _register_controls() {

    $this->start_controls_section(
        'content_section',
        [
            'label' => __( 'Content', 'plugin-name' ),
            'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
    );

    $this->add_control(
        'youtubeid',
        [
            'label' => __( 'Youtube ID', 'plugin-name' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'dynamic' => [
                'active' => true,
            ],
        ]
    );

    $this->add_control(
        'title',
        [
            'label' => __( 'Title', 'plugin-name' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'dynamic' => [
                'active' => true,
            ],
        ]
    );

    $this->end_controls_section();

}

protected function render() {

    $settings = $this->get_settings_for_display();
    echo do_shortcode( '[output_youtube_video title="'. $settings['title'] .'" youtubeid="'. $settings['youtubeid'] .'"]')
}

}

Now beacuse of `dynamic` active :
```PHP
'dynamic' => [
    'active' => true,
],

the controls will have dynamic option enabled.

Amazing, i'll do that :)

Thanks a lot

@bainternet I'm an Elementor Newbie and I would like to re-use the "Products" widgets with parameters.

I would love to define a Products template and then alter the content by adding parameters to the shortcode. This way I could reuse styles while being able to change the content displayed

Something like this
[elementor-template id="7972" taxonomy="product_cat" terms="high-uv-buff" taxonomy2="product_tag" terms2="blue"]
So basically take the template and display Woocommerce products that fit the category High UV Buff庐 and the tag "blue"

Similar stuff I would like to do with the Posts Widget

Is this already possible or is this a feature request?

Was this page helpful?
0 / 5 - 0 ratings