Page Templates - Sidebar Left Content Right

Wordpress 5.1.1
X 6.5.5
Cornerstone 3.5.4

I am using the page template Sidebar left Content Right (template-layout-sidebar-content.php) and my client wants another template like this setup, with something else added to these pages.

I noticed the template-layout-sidebar-content and template-layout-content-sidebar files in X have identical code, even the sidebar is after the content piece, the only difference is the filename and reference in the comments. How is X adding the class Right or Left to these to get them to float correctly?

When I duplicate template-layout-sidebar-content and name it template-layout-sidebar-content-2 in wp-content/themes/x-child/framework/views/integrity/ and add the corresponding file to the child root, it always puts the sidebar right and content left whereas I want content right and sidebar left.

what am I missing here to be able to have multiple templates following the Sidebar Left Content Right template?
Even if I just copy that file exactly (but of course have to name it differently) it is displayed in the wrong order.

Hi @CenturyMarketing,

Thank you for writing in, while that is outside the scope of support, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

Besides adding a new template, you also need to edit a couple of functions to add a case for that new template if its use.

These are the functions that I am referring to.

/*Get Content Layout*/
function x_get_content_layout() {

    $content_layout = x_get_option( 'x_layout_content' );

    if ( $content_layout != 'full-width' ) {
      if ( is_home() ) {
        $opt    = x_get_option( 'x_blog_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
      } elseif ( x_is_portfolio_item() ) {
        $layout = 'full-width';
      } elseif ( x_is_portfolio() ) {
        $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
        $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
      } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
      } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
      } elseif ( is_page_template( 'template-layout-sidebar-content-2.php' ) ) {
        $layout = 'sidebar-content-2';
      } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
      } elseif ( is_archive() ) {
        if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
          $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        } else {
          $opt    = x_get_option( 'x_archive_layout' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        }
      } elseif ( x_is_product() ) {
        $layout = 'full-width';
      } elseif ( x_is_bbpress() ) {
        $opt    = x_get_option( 'x_bbpress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( x_is_buddypress() ) {
        $opt    = x_get_option( 'x_buddypress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_404() ) {
        $layout = 'full-width';
      } else {
        $layout = $content_layout;
      }
    } else {
      $layout = $content_layout;
    }

    return $layout;

  }
/*Main Content Class*/
  function x_main_content_class() {

    switch ( x_get_content_layout() ) {
      case 'content-sidebar' :
        $output = 'x-main left';
        break;
      case ('sidebar-content') || ('sidebar-content-2') :
        $output = 'x-main right custom-class';
        break;
      case 'full-width' :
        $output = 'x-main full';
        break;
    }

    echo $output;

  }
/*Sidebar Class*/
  function x_sidebar_class() {

    switch ( x_get_content_layout() ) {
      case 'content-sidebar' :
        $output = 'x-sidebar right';
        break;
      case ('sidebar-content') || ('sidebar-content-2') :
        $output = 'x-sidebar left custom-class';
        break;
      default :
        $output = 'x-sidebar right';
    }

    echo $output;

  }

You can put a custom function to your child theme’s functions.php file.

Customizations - Best Practices

Hope it helps,
Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.