Skip to content

Changing Available Layouts And Default Layout

Steve Rudolfi edited this page May 29, 2019 · 2 revisions

Changing Available Layouts & Default Layout

Responsive Framework ships with four layout options by default:

  • default
  • top-nav
  • side-nav
  • no-nav
  • mega-nav

default is the default option when:

  • The BU_RESPONSIVE_LAYOUT constant is not defined.
  • The BU_RESPONSIVE_LAYOUT constant is defined, but is not a valid layout.
  • The burf_setting_layout option is not saved in the database (no one has used the Customizer to change the layout setting).

Adding Layout Options

It is possible to add layout options based on the needs of the site.

<?php
/**
 * Add a new responsive layout option.
 *
 * @param array List of layout options.
 *
 * @return array Modified layout options.
 */
function mytheme_responsive_layout_options( $layout_options ) {
	$layout_options['my-custom-layout'] = __( 'My Custom Layout', 'mytheme' );

	return $layout_options;
}
add_filter( 'responsive_layout_options', 'mytheme_responsive_layout_options' );

Removing Layout Options

It is also possible to remove layout options based on the needs of the site.

<?php
/**
 * Remove the `no-nav` responsive layout option.
 *
 * @param array List of layout options.
 *
 * @return array Modified layout options.
 */
function mytheme_responsive_layout_options( $layout_options ) {
	unset( $layout_options['no-nav'] );

	return $layout_options;
}
add_filter( 'responsive_layout_options', 'mytheme_responsive_layout_options' );

Changing Default Layout

There could be a situation where a layout should remain an option in the Customizer, but a different default should be enforced. Say you are building a companion theme and instead of default being the default, top-nav should be the default.

<?php
/**
 * Change the default responsive layout.
 *
 * @param string Default responsive layout.
 *
 * @return string New default responsive layout.
 */
function mytheme_responsive_layout_default( $default_layout ) {
	return 'top-nav';
}
add_filter( 'responsive_layout_default', 'mytheme_responsive_layout_default' );

Welcome to Responsive!

Get started

Configuration

Build child themes

Sass

Javascript

PHP

Shortcodes

Templates

GitHub

Tasks

Contribute to the framework

Code Examples

BU Developer Resources

Clone this wiki locally