A simple one - How to call the correct $atts
Hi there, I have got this code in my options.php but cannot figurate how to call the ['icon'] attribute as $atts['icon'] does not work. Thank you for your help.
Here my options:
'btn_icon' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'gadget' => array(
'label' => __( 'Icon', 'unyson' ),
'type' => 'select',
'value' => 'choice-1',
'desc' => __( 'Should an icon be displayed on the button?', 'fw' ),
'choices' => array(
'choice-1' => __('No', 'fw'),
'choice-2' => __('Yes', 'fw'),
),
),
),
'choices' => array(
'choice-1' => array(
'no' => array(
'type' => 'hidden',
'value' => __( 'none', 'unyson' ),
),
),
'choice-2' => array(
'btn_icon_group' => array(
'type' => 'group',
'options' => array(
'icon' => array(
'type' => 'icon',
'label' => __( 'Icon', 'fw' )
),
'icon_position' => array(
'type' => 'switch',
'label' => __( '', 'fw' ),
'desc' => __( 'Choose the icon position', 'fw' ),
'right-choice' => array(
'value' => 'pull-right',
'label' => __('Right', 'fw'),
),
'left-choice' => array(
'value' => '',
'label' => __('Left', 'fw'),
),
),
)
),
),
),
'show_borders' => false,
),
Hello Alex,
If i understand your question correctly, I can find your solution from the documantation. This is what your need;
$icon = fw_get_db_settings_option(
'btn_icon/'. fw_get_db_settings_option('btn_icon/'. 'gadget')
);
And now you can get your icon with $icon['icon'], it returns something like 'fa fa-angle'. If icon choice set to no than it returns NULL
Thank you for your answer @coderontheroad ;)
As I am not using thess options in the theme settings it is not working. But, good news, I have found the solution. For information, here is the solution ;)
1- I have changed my options.php
'icon_setup' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'selected_value' => array(
'type' => 'select',
'label' => __( 'Icon', 'fw' ),
'desc' => __( 'Should an icon be displayed on the button?', 'fw' ),
'value' => 'icon-yes',
'choices' => array(
'icon' => __('Yes', 'fw'),
'no_icon' => __('No', 'fw'),
),
)
),
'choices' => array(
'icon' => array(
'icon_selected' => array(
'type' => 'icon',
'label' => __( 'Choose an Icon', 'fw' )
),
'icon_position' => array(
'type' => 'switch',
'label' => __( '', 'fw' ),
'desc' => __( 'Choose the icon position', 'fw' ),
'right-choice' => array(
'value' => 'pull-right',
'label' => __('Right', 'fw'),
),
'left-choice' => array(
'value' => '',
'label' => __('Left', 'fw'),
),
),
),
'no_icon' => array(
'no' => array(
'type' => 'hidden',
'value' => __( 'none', 'unyson' ),
),
)
),
'show_borders' => false,
),
2- To Output the $atts in view.php
if (fw_akg('icon_setup/selected_value', $atts) === 'icon'){
$icon_options = fw_akg('icon_setup/icon', $atts);
$icon_position = fw_akg('icon_setup/icon/icon_position', $atts);
$icon = '<i class="'.$icon_options['icon_position'].' '.$icon_options['icon_selected'].'"></i>';
}
I hope that can help. Cheers
Ok, my bad :) you solve the problem thats the important.
Thanks again mate ;)