Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

re: default/en/category_description.tpl

 
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 01-11-2016, 10:55 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 re: default/en/category_description.tpl

our store has approximately 350 categories where the description field has been filled out with the exact same text as the category title, thus we get

CATEGORY TITLE
category title

duplicate text on many pages.

I would like to modify this file so that it detects when they are the same and if so, display nothing .. i.e. do not even include the markup for the
HTML Code:
<div class="category_description">

I've been following the tutorial here, but since I don't get a result back from

Code:
SELECT * FROM xc_view_lists WHERE tpl like '%category_description.tpl";


I am a little confused as to how to proceed, as well as still a bit sketchy on how to write the smarty code.. I can probably figure out the smarty code on my own, but as for the rest, what is the correct way to override this file -- it contains no @ListChild .. and the documentation only describes the single instance where it does.
__________________
--
Scott Godin
Reply With Quote
  #2  
Old 01-12-2016, 04:46 AM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: default/en/category_description.tpl

If you look at the code of default/en/category_description.tpl template file, you will see the following code there:

Code:
<div class="category-description">{getDescription():h}</div>

To implement the feature in question, first you need to customize the template code as follows:

Code:
<div IF="isVisible()" class="category-description">{getDescription():h}</div>

Additionally, you will need to customize the following class/method:

classes/XLite/View/Category.php

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

So that if category description is equal to category title, then return an empty string ''.

See also:
* Developer docs
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #3  
Old 01-12-2016, 07:13 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 Re: default/en/category_description.tpl

http://kb.x-cart.com/display/XDD/Step+2+-+applying+design+changes

1. So insofar as the .tpl is concerned, you're saying that even though it has no @ListChild, I can still override the template file in the manner described above ?

2. I don't see anything on smarty.net regarding the isVisible() -- is this something specific to X-Cart 5?

3. I'm still working through the docs in this section on how to override the MVC classes via module. I'll get back to you on this bit if I remain stuck.
__________________
--
Scott Godin
Reply With Quote
  #4  
Old 01-12-2016, 09:50 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 Re: default/en/category_description.tpl

Quote:
Originally Posted by Scott Godin
http://kb.x-cart.com/display/XDD/Step+2+-+applying+design+changes

1. So insofar as the .tpl is concerned, you're saying that even though it has no @ListChild, I can still override the template file in the manner described above ?

the trace shows the following,
http://i67.tinypic.com/be9geo.jpg

however, adding

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

to my module's runBuildCacheHandler() does not seem to remove that template file from the default skin. The docs in the link don't get into detail on what to do in this case, or at least not in a way I am yet understanding.

We need to expand that section of the docs to include instances such as this, for greater clarification of what's necessary. Meanwhile, I still need to know how to do this. Can you clarify?
__________________
--
Scott Godin
Reply With Quote
  #5  
Old 01-12-2016, 11:16 PM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: default/en/category_description.tpl

X-Cart 5 does not use Smarty. It uses Flexy.

If you would like to change any template, use "Webmaster mode" tool (Look & Feel >> Webmaster mode), do not use "Webmaster Kit" module (it is actually a legacy module).
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #6  
Old 01-12-2016, 11:23 PM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: default/en/category_description.tpl

Besides, you need to create a custom module that would change the logic of the getDescription() method of the class "classes/XLite/View/Category.php, as mentioned earlier.
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #7  
Old 01-13-2016, 09:50 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 Re: default/en/category_description.tpl

Quote:
Originally Posted by seyfin
X-Cart 5 does not use Smarty. It uses Flexy.

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

Quote:
Originally Posted by seyfin
If you would like to change any template, use "Webmaster mode" tool (Look & Feel >> Webmaster mode), do not use "Webmaster Kit" module (it is actually a legacy module).

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
__________________
--
Scott Godin
Reply With Quote
  #8  
Old 01-13-2016, 09:54 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 Re: default/en/category_description.tpl

Quote:
Originally Posted by seyfin
Besides, you need to create a custom module that would change the logic of the getDescription() method of the class "classes/XLite/View/Category.php, as mentioned earlier.

I have created a custom module.

I have successfully overridden .tpl files with my own versions (such as the footer in the Clothing template) that posess an @ListChild directive in their content.

This template file does not posess an @ListChild directive, and following the instructions I have already used to do so in the past, does not work for this instance. Your documentation should clarify that "in the case where this, you need to move on to the next segment _here_, to achieve that goal", as well as being updated to no longer reference the use of Webmaster Kit module.

However using webmaster mode to override a template file with no @ListChild does not make it part of your own module, which was, I thought, the whole point of the exercise -- to keep things organized, prevent updates from overwriting, and keep your changes from being scattered all over the place.
__________________
--
Scott Godin
Reply With Quote
  #9  
Old 01-13-2016, 09:57 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 Re: default/en/category_description.tpl

using Webmaster Mode to merely append a 'test' class to the markup in the template resulted in the following:
HTML Code:
<div class="category-description&nbsp;test">Catering Supplies</div>

clearly not what I had in mind.

looking at it in vim, positioning the cursor over the space, and pressing 'ga' gives me the result that the character under the cursor is not an ASCII 32 (space) but in fact a unicode no-break space Hex 00a0 http://www.fileformat.info/info/unicode/char/00a0/index.htm

in addition to the fact that my spacebar was autoconverted without my specific intent to type such a character, it would also appear that I am UNABLE to copy an EXISTING space character from elsewhere on that very edit block and PASTE it in where I want it. The window refuses utterly to even copy the space character -- i have to select surrounding characters and then delete them from around the space I want after I paste it.
__________________
--
Scott Godin
Reply With Quote
  #10  
Old 01-13-2016, 12:53 PM
  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 Re: default/en/category_description.tpl

so far every attempt I've made to replace Xlite/View/Category.php with my module's Xlite/Module/MHG/TemplateMods/View/Category.php either breaks the store forcing me to do a soft reset, or simply fails to do anything.

Not sure what I'm doing wrong. Does the documentation need updating?

I've updated the template file to use this, via theme_tweaker (though I would much rather have this edited template file as part of my module, since I'm using my module to override it!)
Code:
<div IF="isVisible()" class="category-description">{getDescription():h}</div>

and then added the following to my module (a stripped down and edited copy of Xlite\View\Category.php )

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: /** * X-Cart * * NOTICE OF LICENSE * * This source file is subject to the software license agreement * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://www.x-cart.com/license-agreement.html * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to licensing@x-cart.com so we can send you a copy immediately. * * DISCLAIMER * * Do not modify this file if you wish to upgrade X-Cart to newer versions * in the future. If you wish to customize X-Cart for your needs please * refer to http://www.x-cart.com/ for more information. * * @category X-Cart 5 * @author Qualiteam software Ltd <info@x-cart.com> * @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved * @license http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement * @link http://www.x-cart.com/ */ namespace XLite\Module\MHG\TemplateMods\View; /** * Category widget * * @ListChild (list="center", zone="customer") */ class Category extends \XLite\View\AView { /** * Check widget visibility * * @return boolean */ protected function isVisible() { if ( parent::isTitleVisible() && ($this->getCategory()->getMainTitle() == $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(); } }

I have also tried doing it with
Code:
class Category extends \XLite\View\AView implements \XLite\Base\IDecorator
__________________
--
Scott Godin
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:20 AM.

   

 
X-Cart forums © 2001-2020