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)
-   -   re: default/en/category_description.tpl (https://forum.x-cart.com/showthread.php?t=73391)

seyfin 01-14-2016 04:26 AM

Re: default/en/category_description.tpl
 
Quote:

Originally Posted by Scott Godin
Yes, I have noted that distinction, when looking for Smarty functionality that doesn't exist in Flexy and figured it out from there.

with that being the case, I would highly recommend updating the documentation that I referenced from the knowledgebase to reflect this, as well as deprecating the module if you are phasing it out, so that it no longer runs on current Xcart, and shows up in the module list as not-compatible.

I would like to point out that I was only following the instructions in your own documentation


We are working on the manual update at the moment, hope this article will be also revised soon.

Scott Godin 01-14-2016 08:40 AM

Re: default/en/category_description.tpl
 
That's fine. what about the rest ?

Scott Godin 01-14-2016 10:01 AM

[SOLVED] Re: default/en/category_description.tpl
 
so after much hair pulling and despite the lack of detailed information in the online documentation, I have managed to flail my way to a workable solution while at the same time learning the proper way to do this.

In addition, I would like to point out that I would NOT have figured this out using only webmaster mode... Webmaster Kit module was *invaluable*, ultimately, in figuring out just what was needed, by virtue of the trace image here: http://i67.tinypic.com/be9geo.jpg and the information here http://kb.x-cart.com/display/XDD/Step+2+-+applying+design+changes

The docs don't go into a great deal of detail on what you need to do (athough the first step is mentioned, which lent me a clue) when you need to override something that isn't a member of @ListChild -- in this case, what I needed to add to classes/XLite/Module/MHG/TemplateMods/Main.php was

Code:

public static function runBuildCacheHandler()
{
      parent::runBuildCacheHandler();
        // Override Category view with our own, to prevent display of desc where desc = title
        \XLite\Core\Layout::getInstance()->removeClassFromList('Xlite\View\Category', 'center.bottom');

}


because since it's not a member of @ListChild, this won't work:

Code:

\XLite\Core\Layout::getInstance()->removeTemplateFromList('category_description.tpl', 'center.bottom');

THEN, the other part that's not mentioned clearly in the docs, or earlier in this thread, is that after having done the above, when setting up your view widget, you need to add its template back since it will not do that automatically, specifying the location in your own module's skins/default/en/modules/{Module-ID}/{Module-Name}/, after making sure to get the Namespace right, and noticing we didn't need a Decorator :

Code:

<?php
// vim: set ts=4 sw=4 sts=4 et ft=php.html:

namespace XLite\Module\MHG\TemplateMods\View;

/**
 * Category widget
 *
 * @ListChild (list="center", zone="customer")
 */
class Category extends \XLite\View\AView
{
    // choose our template over theirs for this viewclass
    protected function getDefaultTemplate()
    {
        return 'modules/MHG/TemplateMods/category_description.tpl';
    }

    /**
    * Check widget visibility
    *
    * @return boolean
    */
    protected function isVisible()
    {
       
        // because page title isn't part of getCategory(), it's part of the prime object
        if ( parent::isTitleVisible() && ($this->getPageTitle() == $this->getCategory()->getViewDescription() ) )
        {
            return false;
        }
        else
        {
            return parent::isVisible() && $this->getCategory()->getDescription();
        }
    }

    /**
    * Return description with postprocessing WEB LC root constant
    *
    * @return string
    */
    protected function getDescription()
    {
        return $this->getCategory()->getViewDescription();
    }
}


The part that also threw me until I used App::Ack to search through the classes for it, was that the Category Title is not part of getCategory() but is instead part of the prime object. so
$this->getCategory()->get[Page|Main]Title() etc variations are not going to work.

I leave this here as an example in the hopes of saving someone else time and money.

Scott Godin 01-15-2016 08:55 AM

Re: default/en/category_description.tpl
 
Whoopsy, left a bit of code out of my above solution that caused Simple CMS pages to fail :

Code:

class Category extends \XLite\View\AView
{
        // add this in
        public static function getAllowedTargets()
        {
                $result = parent::getAllowedTargets();
                $result[] = 'category';
                $result[] = 'main';
                return $result;
        }



All times are GMT -8. The time now is 03:10 PM.

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