Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #324068
    rosskilleen
    Participant

    Hi there,

    From an older thread here I got some code to make the sidebar appear on the single product page in woocommerce. However, it is appearing on the wrong side of the page. I have the theme set to show content on right and sidebar on left which it does everywhere else on the site, except these pages. Also, the search box within the sidebar has become too long for the border of the sidebar.

    Hope you can help.

    Many thanks

    Ross

    #324135
    Paul R
    Moderator

    Hi Ross,

    Can you share the code you have copied from the forum and provide us your site url
    so we could take a closer look.

    Thanks

    #324251
    rosskilleen
    Participant

    Hi there,

    Many thanks for your reply. URL is http://lightsign.ie/product/professional-screens/philips-32-professional-display-screen-bdl3250el/

    Code is below:

    if ( ! function_exists( ‘x_get_content_layout’ ) ) :
    function x_get_content_layout() {

    $stack = x_get_stack();
    $content_layout = x_get_option( ‘x_’ . $stack . ‘_layout_content’, ‘content-sidebar’ );

    if ( $content_layout != ‘full-width’ ) {
    if ( is_home() ) {
    $opt = x_get_option( ‘x_blog_layout’, ‘sidebar’ );
    $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_archive() ) {
    if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) {
    $opt = x_get_option( ‘x_woocommerce_shop_layout_content’, ‘sidebar’ );
    $layout = ( $opt == ‘sidebar’ ) ? $content_layout : $opt;
    } else {
    $opt = x_get_option( ‘x_archive_layout’, ‘sidebar’ );
    $layout = ( $opt == ‘sidebar’ ) ? $content_layout : $opt;
    }

    } elseif ( x_is_buddypress() ) {
    $opt = x_get_option( ‘x_buddypress_layout_content’, ‘sidebar’ );
    $layout = ( $opt == ‘sidebar’ ) ? $content_layout : $opt;
    } elseif ( is_404() ) {
    $layout = ‘full-width’;
    } else {
    $layout = $content_layout;
    }
    } else {
    $layout = $content_layout;
    }

    if ( 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-full-width.php’ ) ) {
    $layout = ‘full-width’;
    }

    return $layout;

    }
    endif;

    Very best,

    Ross

    #324314
    Paul R
    Moderator

    Hi Ross,

    Please replace your code with this.

    
     function x_get_content_layout() {
    
        $content_layout = x_get_option( 'x_layout_content', 'content-sidebar' );
    
        if ( $content_layout != 'full-width' ) {
          if ( is_home() ) {
            $opt    = x_get_option( 'x_blog_layout', 'sidebar' );
            $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-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', 'sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            } else {
              $opt    = x_get_option( 'x_archive_layout', 'sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            }
          } elseif ( x_is_product() ) {
             $layout = 'sidebar-content';
          } elseif ( x_is_bbpress() ) {
            $opt    = x_get_option( 'x_bbpress_layout_content', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( x_is_buddypress() ) {
            $opt    = x_get_option( 'x_buddypress_layout_content', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_404() ) {
            $layout = 'full-width';
          } else {
            $layout = $content_layout;
          }
        } else {
          $layout = $content_layout;
        }
    
        return $layout;
    
      }
    

    Hope that helps.

    #325414
    rosskilleen
    Participant

    Hi there,

    Thanks a mil, the code seems to have worked for the sidebar positioning, however the search box is extending way beyond the border: http://lightsign.ie/product/professional-screens/philips-32-professional-display-screen-bdl3250el/

    I was also wonder if it was possible to show the categories in the breadcrumbs. When you are in parent category or sub-categoy, the breadcrumbs appear fine:

    home > products > parent category > sub-category

    But when you are in the single product page the categories disappear and the breadcrumbs appear like:

    home > products > single product

    Is there a way to show the parent and sub categories before the product?

    Thanks for all your help and attention.

    Very best,

    Ross

    #325456
    Paul R
    Moderator

    Hi Ross,

    To fix the search overflowing, you can add this under Custom > CSS in the Customizer.

    
    .widget_product_search form input[type="search"] {
       -webkit-box-sizing: border-box;
       -moz-box-sizing: border-box;  
       box-sizing: border-box;  
    }
    

    With regards to product categories

    I’m sorry, I’m afraid there isn’t a simple way to do this right now. It would require a good deal of modification to the breadcrumbs function (x/framework/functions/global/breadcrumbs.php) This is a good idea though. We’ll add it to a list a feature requests for consideration in future development.

    Thanks

    #325593
    rosskilleen
    Participant

    Ok no problem, thanks a mil for the search box fix.

    Very best,

    Ross

    #325695
    Rupok
    Member

    You are welcome Ross!

    Glad that it helped. Feel free to let us know if you face any other issue. We’ll be happy to assist you.

    Thanks for using X.

    Cheers!

    #326648
    rosskilleen
    Participant

    Hi there,

    Sorry to be a pain! Two product pages are randomly displaying the sidebar at the very bottom of the page and I can’t see any difference between these and the pages that display it in the correct position. URLs are as follows:

    http://lightsign.ie/product/media-players/aopen-de3100-basic-media-player/
    http://lightsign.ie/product/media-players/aopen-digital-engine-de6140-media-player/

    Hope you guys can help.

    Many thanks

    Ross

    #326692
    Paul R
    Moderator

    Hi Ross,

    It looks like there are excess div tags on those pages.

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #327683
    rosskilleen
    Participant
    This reply has been marked as private.
    #327689
    Christopher
    Moderator

    Hi there,

    Before we continue, we need you to update X and VC, install Cornerstone from X Addons -> Extensions and disable X shortcodes plugin.

    Then if you still have issue please update the code in functions.php to :

    //Add sidebar to single product
    // =============================================================================
    
    if ( ! function_exists( 'x_get_content_layout' ) ) :
      function x_get_content_layout() {
    
        $stack          = x_get_stack();
        $content_layout = x_get_option('x_layout_content', 'content-sidebar' );
    
        if ( $content_layout != 'full-width' ) {
          if ( is_home() ) {
            $opt    = x_get_option( 'x_blog_layout', 'sidebar' );
            $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-full-width.php' ) ) {
            $layout = 'full-width';
          } elseif ( is_archive() ) {
            if ( x_is_shop() || x_is_product_category() || x_is_product_tag() || x_is_product() ) {
              $opt    = x_get_option( 'x_woocommerce_shop_layout_content','sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            } else {
              $opt    = x_get_option( 'x_archive_layout', 'sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            }
          } elseif ( x_is_buddypress() ) {
            $opt    = x_get_option( 'x_buddypress_layout_content', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_404() ) {
            $layout = 'full-width';
          } else {
            $layout = $content_layout;
          }
        } else {
          $layout = $content_layout;
        }
    
        return $layout;
    
      }
    endif;
    

    Hope it helps.

  • <script> jQuery(function($){ $("#no-reply-324068 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>