【问题标题】:How to use redux framework sorter option?如何使用 redux 框架排序选项?
【发布时间】:2014-03-14 22:16:36
【问题描述】:

晚上好,我已经设法将 redux 框架嵌入到 WP 主题中并且一切正常,但我更像是一名设计师而不是程序员,我想使用选项类型“sorter”(https://github.com/ReduxFramework/redux-framework/wiki/Fields#sorter)来主页中的“get_template_part”基于启用的列和保存的顺序。

我的输出是 print_r($redux_options['home_blocks']['enabled']):

Array
(
    [placebo] => placebo
    [slider] => Slider
    [highlights] => Highlights
    [services] => Services
    [staticpage] => Static Page
)

我想要这样的东西:

slider = get_template_part('templates/content','slider');
highlights = get_template_part('templates/content','highlights');
services = get_template_part('templates/content','services');
staticpage = get_template_part('templates/content','staticpage');

当然与数组具有相同的顺序,并且如果存在于启用的列中。

我查看了 shoestrap3 以了解他们如何设法使分拣机看起来,但最新版本 (3.1.0.2) 中未使用此选项

【问题讨论】:

    标签: php wordpress themes wordpress-theming redux-framework


    【解决方案1】:

    试试这个

    global $redux_options;
    $layout = $redux_options['home_blocks']['enabled'];
    
    if ($layout): foreach ($layout as $key=>$value) {
    
        switch($key) {
    
            case 'slider': get_template_part( 'templates/content', 'slider' );
            break;
    
            case 'highlights': get_template_part( 'templates/content', 'highlights' );
            break;
    
            case 'services': get_template_part( 'templates/content', 'services' );
            break;
    
            case 'staticpage': get_template_part( 'templates/content', 'staticpage' );    
            break;  
    
        }
    
    }
    
    endif;
    

    【讨论】:

      【解决方案2】:

      这里是 Redux 背后的首席开发人员。此类问题最好在我们的问题跟踪器上提供:https://github.com/ReduxFramework/ReduxFramework/issues

      但是,您的问题的答案在于我们的新文档站点:http://docs.reduxframework.com/redux-framework/fields/sorter/

      这会让你得到你所需要的。

      如果你想进一步了解如何使用 Redux,我们明天将举办一场网络研讨会:https://www2.gotomeeting.com/register/797085722

      希望对您有所帮助。

      【讨论】:

      • 谢谢 Dovy,我已经注册了大约 2 周的网络研讨会 :)。我正在为我的问题寻找更详细的解决方案。如果我找不到解决方案,我将在上面发布的问题跟踪器上打开一个“问题”。祝今晚在网络研讨会上好运
      • 接受的答案的解决方案比文档中使用的 print_r 功能更强大,可能值得添加。
      猜你喜欢
      • 2015-07-21
      • 1970-01-01
      • 1970-01-01
      • 2016-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-14
      相关资源
      最近更新 更多