Redux Framework Sorter字段:模板中的输出

时间:2017-03-17 22:35:03

标签: php wordpress redux-framework

Redux Framework纪录片:docs.reduxframework.com/core/fields/sorter /

后端

屏幕截图:enter image description here

终极版选项-的init.php

我只是想测试foreach / switch的输出,但是没有回音的日期

    Redux::setSection( $opt_name, array(
'title'      => __( 'Sorter', 'redux-framework-demo' ),
'id'         => 'additional-sorter',
'subsection' => false,
'fields'     => array(
    array(
        'id'       => 'opt-homepage-layout',
        'type'     => 'sorter',
        'title'    => 'Layout Manager Advanced',
        'subtitle' => 'You can add multiple drop areas or columns.',
        'compiler' => 'true',
        'options'  => array(
            'enabled'  => array(
                'highlights' => 'Highlights',
                'slider'     => 'Slider',
                'staticpage' => 'Static Page',
                'services'   => 'Services'
            ),
            'disabled' => array(),
            'backup'   => array(),
        ),
        'limits'   => array(
            'disabled' => 1,
            'backup'   => 2,
        ),
    ),
    array(
        'id'       => 'opt-homepage-layout-2',
        'type'     => 'sorter',
        'title'    => 'Homepage Layout Manager',
        'desc'     => 'Organize how you want the layout to appear on the homepage',
        'compiler' => 'true',
        'options'  => array(
             'enabled'  => array(
                'highlights' => 'Highlights',
                'slider'     => 'Slider',
                'staticpage' => 'Static Page',
                'services'   => 'Services'
            ),
            'disabled' => array(
            ),
        ),
    ),
)
));

模板

屏幕截图print_r
enter image description here

我只是想测试foreach / switch的输出,但是没有回音的日期

global $redux_data; 

echo 'Enabled column' . '<br />'; 
print_r ($redux_data['opt-homepage-layout-2']['enabled']);

echo '<br /><br />Disabled column' . '<br />'; 
print_r ($redux_data['opt-homepage-layout-2']['disabled']); 


global $redux_options;
$layout = $redux_options['opt-homepage-layout-2']['enabled'];

if ($layout): foreach ($layout as $key=>$value) {

    switch($key) {

        case 'slider': echo "slider";
        break;

        case 'highlights': echo "highlights";
        break;

        case 'services': echo "services";
        break;

        case 'staticpage': echo "services"; 
        break;  

    }

}

endif;

1 个答案:

答案 0 :(得分:0)

搞定了

global $redux_options;
$layout = $redux_options['opt-homepage-layout-2']['enabled'];

更改为:

global $redux_data; // My var name $opt_name
$layout = $redux_date['opt-homepage-layout-2']['enabled']; // My var name $opt_name