View Single Post
  #13  
Old 01-14-2016, 10:01 AM
  Scott Godin's Avatar 
Scott Godin Scott Godin is offline
 

Advanced Member
  
Join Date: Aug 2014
Location: /diagonally parked in a parallel universe/
Posts: 68
 

Default [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
Reply With Quote