Search code examples
phpwordpressvisual-composer

Select type in custom visual composer item


I am trying to make a custom visual composer item for my theme. I made everything right until now. but here, I want to make select choice for my item to check it if it was first value show something and if was second value show something else and so on. but I don't know how to make that select. this is my php file codes in Mapping part:

<?php
// Element Mapping
    public function vc_showcase_mapping() {
         
        // Stop all if VC is not enabled
        if ( !defined( 'WPB_VC_VERSION' ) ) {
            return;
        }
         
        // Map the block with vc_map()
        vc_map( 
            array(
                'name' => __('Showcase', 'filmview'),
                'base' => 'vc_showcase',
                'description' => __('Showcase', 'filmview'), 
                'category' => __('filmview', 'filmview'),   
                'icon' => get_template_directory_uri().'/vc-elements/img/vc-showcase.png',            
                'params' => array(   
                         
                    array(
                        'type' => 'input',
                        'holder' => '',
                        'class' => '',
                        'heading' => __( 'Showcase type', 'filmview' ),
                        'param_name' => 'showcase-type',
                        'value' => __( 'showcase-1', 'filmview' ),
                        'description' => __( 'select type', 'filmview' ),
                        'admin_label' => false,
                        'weight' => 0,
                        'group' => 'settings',
                    ),                        
                ),
            )
        );                                
        
    }
 ?>


Solution

  • I got my answer and here there is :

    I just had to change 'value' => __( 'showcase-1', 'filmview' ), to :

    'value' => array(
    array(
    'value' => 'showcase-1',
    'label' => __( 'showcase type 1', 'filmview' ),
    ),
    array(
    'value' => 'showcase-2',
    'label' => __( 'showcase type 2', 'filmview' ),
    ),
    )