0

I'm using the Redux Wordpress Framework and am having a little trouble retrieving the data for pages in the sorter.

Here's is my array, with "Pages" being pulled as the data, as well as my pre-set options.

array(
                    'id'        => 'opt-homepage-layout',
                    'type'      => 'sorter',
                    'title'     => 'Layout Manager ',
                    'subtitle'  => 'Organise how you want the layout on the home page',
                    'compiler'  => 'true',
                    'data' => array('disabled' => 'pages'),
                    'options'   => array(
                        'enabled'   => array(
                            'hero'          => 'Hero',
                            'menu'          => 'Menu',
                            /*'team'            => 'Team',
                            'quote'         => 'Quote',
                            'portfolio'     => 'Portfolio',
                            'testimonial'   => 'Testimonial',
                            'prices'        => 'Prices',*/
                            'map'           => 'Map',
                            'contact'       => 'Contact'
                        ),
                        'disabled'  => array(
                        ),
                        'backup'    => array(
                        ),
                    ),
                    'limits' => array(
                        'disabled'  => 10,
                        'backup'    => 20,
                    ),
                ),

Here is what I have for the front end, which displays my pre-defined blocks just fine, I just can't get the code to display the dynamic pages, I've searched everywhere and all dead-ends so far.

$layout = $redux_option['opt-homepage-layout']['enabled'];

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

    switch($key) {

        case 'hero': get_template_part( 'templates/content', 'Hero' );
        include(dirname(__FILE__) . '/../includes/hero.php');
        break;

        case 'menu': get_template_part( 'templates/content', 'Menu' );
        include(dirname(__FILE__) . '/../includes/nav.php');
        break;

        case 'team': get_template_part( 'templates/content', 'Team' );
        include(dirname(__FILE__) . '/../includes/team.php');
        break;

        case 'quote': get_template_part( 'templates/content', 'Quote' );
        include(dirname(__FILE__) . '/../includes/quote.php');
        break;

        case 'portfolio': get_template_part( 'templates/content', 'Portfolio' );
        include(dirname(__FILE__) . '/../includes/portfolio.php');
        break;

        case 'testimonial': get_template_part( 'templates/content', 'Testimonial' );
        include(dirname(__FILE__) . '/../includes/testimonial.php');
        break;

        case 'prices': get_template_part( 'templates/content', 'Prices' );
        include(dirname(__FILE__) . '/../includes/prices.php');
        break;

        case 'map': get_template_part( 'templates/content', 'Map' );
        print_r ('<div id="map"></div>');
        break;

        case 'contact': get_template_part( 'templates/content', 'Contact' );
        include(dirname(__FILE__) . '/../includes/contact.php');
        break;

        case 'pages': get_template_part( 'templates/content', 'Pages' );
        include(dirname(__FILE__) . '/../includes/contact.php');
        break;

    }

}

endif;

Your help would be great!

Nisse Engström
  • 4,555
  • 22
  • 24
  • 38
Lee
  • 48
  • 1
  • 5

1 Answers1

0

I use the following to display (or hide) template parts that have been selected via 'opt-homepage-layout' field within wp-admin.

<?php global $redux_option;
$layout = $redux_option['opt-homepage-layout']['enabled'];

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

    switch($key) {

        case 'jumbotron': get_template_part( 'partials/home', 'jumbotron' );
        break;

        case 'jumbotron': get_template_part( 'partials/home', 'slides' );
        break;

        case 'overview': get_template_part( 'partials/home', 'overview' );
        break;

        case 'tickets': get_template_part( 'partials/home', 'tickets' );
        break;

        case 'history': get_template_part( 'partials/home', 'history' );    
        break;  

        case 'contact': get_template_part( 'partials/footer', 'contact' );    
        break; 
    }

}

endif; ?>
katiedev
  • 23
  • 5
  • Code-only answers aren't very useful. Can you explain why the OP should use your code? I'm happy to remove my -1 if you can edit your post. – DeanOC Jul 04 '14 at 04:28