Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Getting multipicker option value

Open webangon opened this issue 11 years ago • 6 comments

Hi I am making options for shortcode . So far my code

'style' => array(
    'type'     => 'multi-picker',
    'label'    => false,
    'desc'     => false,
    'picker' => array(
        'ruler_type' => array(
            'type'    => 'select',
            'label'   => __( 'Icon or Image', 'fw' ),
            'desc'    => __( 'Choose icon or image', 'fw' ),
            'choices' => array(
                'icon'  => __( 'Icon', 'fw' ),
                'image' => __( 'Image', 'fw' ),
            )
        )
    ),

    'choices'     => array(
        'icon' => array(
            'icon_selected' => array(
            'type'  => 'icon',
            'label' => __('Choose an Icon', 'fw'),
           ),

            'icon_color' => array(
            'type'  => 'color-picker',
            'label' => __('Choose Icon color', 'fw'),
           ),

            'icon_size' => array(
            'type'  => 'slider',
            'label' => __('Icon font size', 'fw'),
            'value' => 33,
            'properties' => array(
                'min' => 0,
                'max' => 100,
                'sep' => 1,
                )
           ),              
        ),
        'image' => array(
            'image_selected'  => array(
            'label' => __( 'Choose an image', 'fw' ),
            'desc'  => __( 'Please use 30px by 30px png image', 'fw' ),
            'type'  => 'upload',
            ),
        )           
    )
),

Now How can I get the color picker value? I have tried<?php echo $atts['icon']['icon_selected']; ?>

webangon avatar Jul 25 '15 10:07 webangon

First the ruler_type should say gadget http://manual.unyson.io/en/latest/options/built-in-option-types.html#multi-picker http://prntscr.com/7wsc08

    'picker' => array(
        'gadget' => array(
            'type'    => 'select',
            'label'   => __( 'Icon or Image', 'fw' ),
            'desc'    => __( 'Choose icon or image', 'fw' ),
            'choices' => array(
                'icon'  => __( 'Icon', 'fw' ),
                'image' => __( 'Image', 'fw' ),
            )
        )
    ),

than add this in the view.php and echo those vars

$picker_option          = fw_akg('style/gadget',$atts); // currently selected 
$picker_icon            = fw_akg('style/icon/icon_selected',$atts); // selected icon

more about fw_akg function

https://github.com/ThemeFuse/Unyson/blob/fc80d6a1b7cbe1ec30ed8ae18e88b2a6dbb4cc09/framework/helpers/general.php#L15

and use

fw_print(fw_akg('style',$atts));

to see the full option array

danyj avatar Jul 25 '15 10:07 danyj

@danyj First the ruler_type should say gadget

No, you can name that key however you want.


http://manual.unyson.io/en/latest/options/built-in-option-types.html#multi-picker-get-db-value

ghost avatar Jul 25 '15 10:07 ghost

@moldcraft thnx bud , I was under impression that it was option var

danyj avatar Jul 25 '15 10:07 danyj

@webangon corrected version than

$picker_option          = fw_akg('style/ruler_type',$atts); // currently selected 
$picker_icon            = fw_akg('style/icon/icon_selected',$atts); // selected icon
fw_print(fw_akg('style',$atts));

danyj avatar Jul 25 '15 10:07 danyj

if (fw_akg('style/ruler_type', $atts) === 'icon') {
    $icon_options = fw_akg('style/icon', $atts);
    echo $icon_options['icon_color'];
    // or: echo fw_akg('style/icon/icon_color', $atts);
}

ghost avatar Jul 25 '15 10:07 ghost

Thank you very much .

webangon avatar Jul 25 '15 10:07 webangon