Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have added a new layout for the genesis framework called "modalwindow". This layout should only display the content because it is a modal window loading page content (I don't want any of the header, sidebars, footers, menus or anything else displayed, just the content from that page).

What do I add for it to only display the content of that page with nothing else? ie: code to remove header, sidebars, footers, menus, etc. At the moment I have selected the "modalwindow" layout for the page in WP admin- now need to strip everything from the content.

Code:

// from "/themes/genesis/lib/structure/layout.php"

<?php
/**
 * Controls layout structure.
 *
 * @package Genesis
 */

add_filter( 'content_width', 'genesis_content_width', 10, 3 );
/**
 * This function filters the content width based on the user selected layout.
 *
 * @since 1.6
 */
function genesis_content_width( $default, $small, $large ) {

    switch ( genesis_site_layout() ) {
        case 'full-width-content':
            $width = $large;
            break;
        case 'content-sidebar-sidebar':
        case 'sidebar-content-sidebar':
        case 'sidebar-sidebar-content':
            $width = $small;
            break;
        default:
            $width = $default;
    }

    return $width;

}

add_filter('body_class', 'genesis_custom_body_class', 15);
/**
 * This function/filter adds custom body class(es) to the
 * body class array. It accepts values from a per-post/page
 * custom field, and only outputs when viewing singular page.
 *
 * @since 1.4
 */
function genesis_custom_body_class( $classes ) {

    $new_class = is_singular() ? genesis_get_custom_field( '_genesis_custom_body_class' ) : null;

    if ( $new_class ) $classes[] = esc_attr( sanitize_html_class( $new_class ) );

    return $classes;

}

add_action('genesis_meta', 'genesis_load_stylesheet');
/**
 * This function loads the stylesheet.
 * If a child theme is active, it loads the child theme's stylesheet,
 * otherwise, it loads the Genesis stylesheet.
 *
 */
function genesis_load_stylesheet() {

    echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_url').'" type="text/css" media="screen" />'."\n";

}

add_filter('body_class', 'genesis_header_body_classes');
/**
 * This function/filter adds new classes to the <body>
 * so that we can use psuedo-variables in our CSS file,
 * which helps us achieve multiple header layouts with minimal code
 *
 * @since 0.2.2
 */
function genesis_header_body_classes($classes) {

    // add header classes to $classes array
    if ( ! is_active_sidebar( 'header-right' ) )
        $classes[] = 'header-full-width';

    if ( 'image' == genesis_get_option('blog_title') || 'blank' == get_header_textcolor() )
        $classes[] = 'header-image';

    // return filtered $classes
    return $classes;

}

add_filter('body_class', 'genesis_layout_body_classes');
/**
 * This function/filter adds new classes to the <body>
 * so that we can use psuedo-variables in our CSS file,
 * which helps us achieve multiple site layouts with minimal code
 *
 * @since 0.2.2
 */
function genesis_layout_body_classes($classes) {

    // get the layout
    $site_layout = genesis_site_layout();

    // add new class to $classes array
    if ( $site_layout ) $classes[] = $site_layout;

    // return filtered $classes
    return $classes;
}

add_action('genesis_after_content', 'genesis_get_sidebar');
/**
 * This function outputs the sidebar.php file
 * if specified in theme options or in-post options
 *
 * @since 0.2
 */
function genesis_get_sidebar() {

    // get the layout
    $site_layout = genesis_site_layout();

    // don't load sidebar on pages that don't need it
    if ( $site_layout == 'full-width-content' ||
        $site_layout == 'modalwindow' ) return;

    // output the primary sidebar
    get_sidebar();
}

add_action('genesis_after_content_sidebar_wrap', 'genesis_get_sidebar_alt');
/**
 * This function outputs the sidebar_alt.php file
 * if specified in theme options or in-post options
 *
 * @since 0.2
 */
function genesis_get_sidebar_alt() {

    // get the layout
    $site_layout = genesis_site_layout();

    // don't load sidebar-alt on pages that don't need it
    if ( $site_layout == 'content-sidebar' ||
        $site_layout == 'sidebar-content' ||
        $site_layout == 'full-width-content' ||
        $site_layout == 'modalwindow' ) return;

    // output the alternate sidebar
    get_sidebar('alt');

}

Code:

// from "/themes/genesis/lib/functions/layout.php"

<?php
/**
 * Register default Genesis layouts.
 *
 * @package Genesis
 */

add_action('genesis_init', 'genesis_create_initial_layouts', 0);
/**
 * Creates the initial layouts when the 'init' action is fired
 *
 * @since 1.4
 */
function genesis_create_initial_layouts() {

    genesis_register_layout( 'content-sidebar', array(
        'label' => __('Content-Sidebar', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/cs.gif',
        'default' => true
    ) );

    genesis_register_layout( 'sidebar-content', array(
        'label' => __('Sidebar-Content', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/sc.gif'
    ) );

    genesis_register_layout( 'content-sidebar-sidebar', array(
        'label' => __('Content-Sidebar-Sidebar', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/css.gif'
    ) );

    genesis_register_layout( 'sidebar-sidebar-content', array(
        'label' => __('Sidebar-Sidebar-Content', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/ssc.gif'
    ) );

    genesis_register_layout( 'sidebar-content-sidebar', array(
        'label' => __('Sidebar-Content-Sidebar', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/scs.gif'
    ) );

    genesis_register_layout( 'full-width-content', array(
        'label' => __('Full Width Content', 'genesis'),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/c.gif',
    ) );

    genesis_register_layout( 'modalwindow', array(
        'label' => __('Sizing Guide Layout', 'genesis'),
        'img' => CHILD_URL . '/images/stcsb.gif',
    ) );
}

/**
 * This function registers new layouts by modifying the global
 * $_genesis_layouts variable.
 *
 * @since 1.4
 */
function genesis_register_layout( $id = '', $args = array() ) {

    global $_genesis_layouts;

    if ( !is_array( $_genesis_layouts ) )
        $_genesis_layouts = array();

    // Don't allow empty $id, or double registrations
    if ( !$id || isset( $_genesis_layouts[$id] ) )
        return false;

    $defaults = array(
        'label' => __( 'No Label Selected', 'genesis' ),
        'img' => GENESIS_ADMIN_IMAGES_URL . '/layouts/none.gif',
    );

    $args = wp_parse_args( $args, $defaults );

    $_genesis_layouts[$id] = $args;

    return $args;

}

/**
 * This function allows a user to identify a layout as being the default
 * layout on a new install, as well as serve as the fallback layout.
 *
 * @since 1.4
 */
function genesis_set_default_layout( $id = '' ) {

    global $_genesis_layouts;

    if ( !is_array( $_genesis_layouts ) )
        $_genesis_layouts = array();

    // Don't allow empty $id, or double registrations
    if ( !$id || !isset( $_genesis_layouts[$id] ) )
        return false;

    // remove default flag for all other layouts
    foreach ( (array)$_genesis_layouts as $key => $value ) {
        if ( isset( $_genesis_layouts[$key]['default'] ) ) {
            unset( $_genesis_layouts[$key]['default'] );
        }
    }

    $_genesis_layouts[$id]['default'] = true;

    return $id;

}

/**
 * This function unregisters layouts by modifying the global
 * $_genesis_layouts variable.
 *
 * @since 1.4
 */
function genesis_unregister_layout( $id = '' ) {

    global $_genesis_layouts;

    if ( !$id || !isset( $_genesis_layouts[$id] ) )
        return false;

    unset( $_genesis_layouts[$id] );

    return true;

}

/**
 * This function returns all registered Genesis Layouts
 *
 * @since 1.4
 */
function genesis_get_layouts() {

    global $_genesis_layouts;

    if ( !is_array( $_genesis_layouts ) )
        $_genesis_layouts = array();

    return $_genesis_layouts;

}

/**
 * This function returns the data from a single layout,
 * specified by the $id passed to it.
 *
 * @since 1.4
 */
function genesis_get_layout( $id ) {

    $layouts = genesis_get_layouts();

    if ( !$id || !isset( $layouts[$id] ) )
        return;

    return $layouts[$id];

}

/**
 * This function returns the layout that is set to default.
 *
 * @since 1.4
 */
function genesis_get_default_layout() {

    global $_genesis_layouts;

    $default = '';

    foreach ( (array)$_genesis_layouts as $key => $value ) {
        if ( isset( $value['default'] ) && $value['default'] ) {
            $default = $key; break;
        }
    }

    // return default layout, if exists
    if ( $default ) {
        return $default;
    }

    return 'nolayout';

}

/**
 * This function checks both the custom field and
 * the theme option to find the user-selected site
 * layout, and returns it.
 *
 * @since 0.2.2
 */
function genesis_site_layout() {

    // If viewing a singular page/post
    if ( is_singular() ) {

        $custom_field = genesis_get_custom_field( '_genesis_layout' );
        $site_layout = $custom_field ? $custom_field : genesis_get_option( 'site_layout' );

    }

    // If viewing a taxonomy archive
    elseif ( is_category() || is_tag() || is_tax() ) {
        global $wp_query;

        $term = $wp_query->get_queried_object();

        $site_layout = $term && isset( $term->meta['layout'] ) && $term->meta['layout'] ? $term->meta['layout'] : genesis_get_option( 'site_layout' );

    }

    // If viewing an author archive
    elseif( is_author() ) {

        $site_layout = get_the_author_meta( 'layout', (int)get_query_var('author') ) ? get_the_author_meta( 'layout', (int)get_query_var('author') ) : genesis_get_option('site_layout');

    }

    // else pull the theme option
    else {

        $site_layout = genesis_get_option( 'site_layout' );

    }

    // Use default layout as a fallback, if necessary
    if ( !genesis_get_layout( $site_layout ) ) {
        $site_layout = genesis_get_default_layout();
    }

    return esc_attr( apply_filters( 'genesis_site_layout', $site_layout ) );

}

/**
 * A helper function that outputs the form elements necessary to select a layout.
 *
 * You must manually wrap this in an HTML element with the class of 'genesis-layout-selector'
 * in order for the CSS and Javascript to apply properly.
 *
 * @since 1.7
 */
function genesis_layout_selector( $args = array() ) {

    /** Merge defaults with user args */
    $args = wp_parse_args( $args, array(
        'name'     => '',
        'selected' => '',
        'echo'     => true
    ) );

    $output = '';

    foreach ( genesis_get_layouts() as $id => $data ) {

        $class = $id == $args['selected'] ? 'selected' : '';

        $output .= sprintf( '<label title="%1$s" class="box %2$s"><img src="%3$s" alt="%1$s" /><br /> <input type="radio" name="%4$s" id="%5$s" value="%5$s" %6$s /></label>',
                esc_attr( $data['label'] ),
                esc_attr( $class ),
                esc_url( $data['img'] ),
                esc_attr( $args['name'] ),
                esc_attr( $id ),
                checked( $id, $args['selected'], false )
        );

    }

    /** Echo or Return output */
    if ( $args['echo'] )
        echo $output;
    else
        return $output;

}

/**
* A helper function to do the logic, and potentially echo/return a structural wrap div.
*
* @since 1.6
*/
function genesis_structural_wrap( $context = '', $output = '<div class="wrap">', $echo = true ) {

    $genesis_structural_wraps = get_theme_support( 'genesis-structural-wraps' );

    if ( ! in_array( $context, (array) $genesis_structural_wraps[0] ) )
        return '';

    switch( $output ) {
        case 'open':
            $output = '<div class="wrap">';
            break;
        case 'close':
            $output = '</div><!-- end .wrap -->';
            break;
    }

    if ( $echo )
        echo $output;
    else
        return $output;

}

/**
 * Helper function for returning layout key 'content-sidebar'.
 *
 * @since 1.7
 */
function __genesis_return_content_sidebar() {
    return 'content-sidebar';
}

/**
 * Helper function for returning layout key 'sidebar-content'.
 *
 * @since 1.7
 */
function __genesis_return_sidebar_content() {
    return 'sidebar-content';
}

/**
 * Helper function for returning layout key 'content-sidebar-sidebar'.
 *
 * @since 1.7
 */
function __genesis_return_content_sidebar_sidebar() {
    return 'content-sidebar-sidebar';
}

/**
 * Helper function for returning layout key 'sidebar-sidebar-content'.
 *
 * @since 1.7
 */
function __genesis_return_sidebar_sidebar_content() {
    return 'sidebar-sidebar-content';
}

/**
 * Helper function for returning layout key 'sidebar-content-sidebar'.
 *
 * @since 1.7
 */
function __genesis_return_sidebar_content_sidebar() {
    return 'sidebar-content-sidebar';
}

/**
 * Helper function for returning layout key 'full-width-content'.
 *
 * @since 1.7
 */
function __genesis_return_full_width_content() {
    return 'full-width-content';
}

/**
 * Helper function for returning layout key 'modalwindow'.
 *
 * @since 1.7
 */
function __genesis_return_modalwindow_content() {
    return 'modalwindow';
}
share|improve this question

1 Answer 1

I have attempted answering my own question with the following code:

// Added to layout.php in /genesis/lib/structure.php

add_action('genesis_before', 'modalwindow_layout_logic');

    function modalwindow_layout_logic() {

        $site_layout = genesis_site_layout();

        if ( $site_layout == 'modalwindow' ) {
            // Remove default genesis sidebars
            remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
            remove_action( 'genesis_after_content_sidebar_wrap', 'genesis_get_sidebar_alt');
            remove_action( 'genesis_footer', 'genesis_do_footer' );  
            remove_action( 'genesis_header', 'genesis_do_header' );  
            // Remove layout specific sidebars
            remove_action('genesis_before_header', 'genesis_do_nav');
            remove_action('genesis_after_header', 'genesis_do_subnav');
            remove_action('genesis_header', 'genesis_do_nav');
            remove_action('genesis_footer','themedy_footer_menu');
            remove_action('genesis_before_loop', 'genesis_do_breadcrumbs'); // Remove Breadcrumbs by default
            remove_action('genesis_after_header','themedy_secondary_area');
        }
    }

There seems to be more that needs removing- any idea? Thanks

share|improve this answer
    
Why don't you just ask this on the Genesis support forums? I thought they provided pretty good support and had a large community of developers over there. –  Chris_O May 6 '12 at 1:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.