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)
-   -   X-Cart 5 Remove Categories from Homepage body (https://forum.x-cart.com/showthread.php?t=68797)

Dbaker 03-08-2014 09:46 PM

X-Cart 5 Remove Categories from Homepage body
 
I was trying to remove the icons for the categories on the body of the homepage. Any assistance would be greatly appreciated.

tony_sologubov 03-11-2014 03:02 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
Hi!

Thanks for asking! First thing to try is to apply the following CSS code via the System Settings > Look & feel > Custom CSS section in your admin area:

Code:

ul.subcategory-list {
    display: none;
}


Please, let me know if it works for you.

Note: this approach will hide the subcategories from all the pages, not from home page only.

Luisv 03-11-2014 07:23 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
I also want to know how to remove the categories from the bottom of the front page. Tony, your fix works but it also removed the sub-categories from the categories page. So when you click on a category you are taken to the page but it then does not show the sub-categories list. Any idea how to just remove them from the bottom of the main page? I have lots so it look bad on the main page.
Thank you.

tony_sologubov 03-12-2014 10:56 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
Hi Luis!

In this case, you need to create a simple mod. Create the module according to the article here:
http://kb.x-cart.com/display/XDD/How+to+create+a+module

and then add an additional class to your module:
<Module-root>/View/Subcategories.php

This class will decorate the \XLite\View\Subcategories class and it will re-define the getAllowedTargets() {} method. It should return array('category'), not array('category', 'main').

Please, let me know if it makes sense to you. If it is over-complicated, I will try to explain it in more details.

Luisv 03-12-2014 11:40 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
Thank you for reply. I am confused. Should I create a file called main.php and add all the text from the "sample" except use the correct names for XLite\Module\Tony\Example; (XLite\Module\myMode\myname)? Then add "<Module-root>/View/Subcategories.php" to the bottom of the Mod?

Sorry, I guess I'll need a more detailed explanation.

tony_sologubov 03-12-2014 01:03 PM

Re: X-Cart 5 Remove Categories from Homepae body
 
OK, let's start with one simple thing. Create the module according to the article above, but with your own Developer and Module IDs.

Once you are done, please let me know your Developer and Module IDs and I will suggest you about next step.

Luisv 03-12-2014 01:51 PM

Re: X-Cart 5 Remove Categories from Homepae body
 
Ok, I've created a Mod and enable it on my site (to test) and it works (no errors anyway). I'm not sure that it does anything. The identifiers are "Lou" and "Catsub"


This is the code I used and named "Main.php". Thanks you.


<?php
// vim: set ts=4 sw=4 sts=4 et:
namespace XLite\Module\Lou\Catsub;
/**
* Module description
*
* @package XLite
*/
abstract class Main extends \XLite\Module\AModule
{
/**
* Author name
*
* @return string
*/
public static function getAuthorName()
{
return 'Lou';
}

/**
* Module name
*
* @return string
*/
public static function getModuleName()
{
return 'Catsub';
}

/**
* Get module major version
*
* @return string
*/
public static function getMajorVersion()
{
return '5.0';
}

/**
* Module version
*
* @return string
*/
public static function getMinorVersion()
{
return 0;
}

/**
* Module description
*
* @return string
*/
public static function getDescription()
{
return 'This Mod will show Categories on pages but not front';
}
}

tony_sologubov 03-19-2014 05:03 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
That is good that you created the module. Indeed, it does not do anything at this point.

Next thing to do is to create the XLite/Module/Lou/Catsub/View/Subcategories.php file with the following content:

PHP Code:

<?php

namespace XLite\Module\Lou\Catsub\View;

class 
Subcategories extends \XLite\View\Subcategories implements \XLite\Base\IDecorator
{
    public static function 
getAllowedTargets()
    {
        
$targets parent::getAllowedTargets();
        
$return = array();
        
        foreach (
$targets as $target) {
            if (
$target != 'main') {
                
$return[] = $target
            }
        }

        return 
$return;
    }
}


and it should do the trick.

I will explain what this code does: you are taking default viewer XLite\View\Subcategories and decorate (change) it that it should be displayed only upon calling cart.php?target=category , so it would not work upon calling cart.php?target=main as it works by default.

Please, try this code and let me know whether it works for you.

Tony.

Luisv 03-19-2014 09:34 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
Works perfectly! Thanks for your help.

tony_sologubov 03-20-2014 04:01 AM

Re: X-Cart 5 Remove Categories from Homepae body
 
Happy to hear that!


All times are GMT -8. The time now is 12:27 PM.

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