X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Add sidebar to product pages (https://forum.x-cart.com/showthread.php?t=70257)

Phil Richman 10-15-2014 12:11 PM

Add sidebar to product pages
 
I'm wanting to add the sidebar to the product pages like it is on the home page and category pages.

totaltec 10-15-2014 12:32 PM

Re: Add sidebar to product pages
 
Phil,

Look in:
XLite/View/Controller.php

Code:

protected static function getSidebarFirstHiddenTargets()
{
    return array(
        'cart',
        'product',
        'checkout',
        'checkoutPayment',
        'checkoutSuccess',
    );
}


I would try extending/decorating this class, then redefining this method. Leave out the line for 'product'.

If that works, you might still have some CSS playing to do.

Phil Richman 10-15-2014 12:40 PM

Re: Add sidebar to product pages
 
Thanks again Mike you're the man. That worked.

DesignByKiltz 03-05-2015 08:15 AM

Re: Add sidebar to product pages
 
Can you change the controller.php file in a custom skin/module? If so, where do you put your version of the file?

totaltec 03-08-2015 05:33 AM

Re: Add sidebar to product pages
 
Your version of the file should go in the same place that it did in the default structure.

So if the original file is XLite\View\Controller and you want to decorate this class, and your module is in classes\XLite\DevID\ModuleName

Then your file would go in classes\XLite\DevID\ModuleName\View\Controller.php and it would contain the following:
Code:

<?php


namespace XLite\DevID\ModuleName\View;

/**
 * Controller main widget
 */
class Controller extends \XLite\View\Controller implements \XLite\Base\IDecorator
{
    /**
    * Define the pages where first sidebar will be hidden.
    * By default we hide it on:
    *      product page,
    *      cart page,
    *      checkout page
    *      checkout success (invoice) page
    *      payment page
    *
    * @return array
    */
    protected static function getSidebarFirstHiddenTargets()
    {
        return array(
            'cart',
            /*'product', Commented out to allow sidebar on product page */
            'checkout',
            'checkoutPayment',
            'checkoutSuccess',
        );
    }
}


xgarb 03-09-2015 10:46 AM

Re: Add sidebar to product pages
 
in v5.2 the method getSidebarFirstHiddenTargets() is in classes/XLite/Core

alarmsellout 03-14-2015 02:27 PM

Re: Add sidebar to product pages
 
I changed the controller.php file as this forum shows, but the sidebar isn't showing up on my product page. Do I have to reset the cache or something? How do I do that?

XCart 5.1.11

totaltec 03-15-2015 05:22 AM

Re: Add sidebar to product pages
 
Quote:

Originally Posted by alarmsellout
I changed the controller.php file as this forum shows, but the sidebar isn't showing up on my product page. Do I have to reset the cache or something? How do I do that?

XCart 5.1.11

Hopefully you are working in your own custom module and not changing core files. Don't change core files!

To answer your question, yes you need to rebuild the cache/redeploy the store. You will see the option in the admin menu.

If working on a live store, you first make a full backup. You need to backup the database and the files.

alarmsellout 03-15-2015 09:35 AM

Re: Add sidebar to product pages
 
Yes, I did change the core file... I just re-built the store and it took effect. However, it didn't do quite what I was hopping for so I changed it back. Why shouldn't the core file be changed? Upgrade problems later or...?

I've always changed the core files in xCart 4... but never upgraded it so maybe it didn't matter because of that.. not sure?

The main problem I have found with X-Cart is upgrading after any custom work is completed. I was hoping that problem would be fixed in version 5... I may be going about this incorrectly.

I'm not using a live store right now.. just a test store until I can get it setup correctly. Then I'll switch it to the live server.

cflsystems 03-15-2015 09:40 AM

Re: Add sidebar to product pages
 
XC5 pushes upgrades live and overwrites files without even telling you. So if you modify core files directly next upgrade will overwrite them with newer files (if applicable) and your changes will be lost.

You have to write your own module(s) to make any changes to XC5.


All times are GMT -8. The time now is 09:30 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.