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

Overriding a skin module with my DropDown Module

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-20-2014, 04:59 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Overriding a skin module with my DropDown Module

Hi all posting this here so I can understand and others can learn.

Here is a video explaining the problem, and it is outlined again below.

http://youtu.be/ThJlxRRxQac

The module needs to unset the default Category List, and replace it with the DropDown Menu.

I have correctly assigned my template to the appropriate list using:
Code:
/** * @ListChild (list="layout.header.bar", zone="customer", weight="140") */
In my XLite\Module\Baby\DropDown\View\DropDown.php class

I now need to unset the template default/en/categories/list/body.tpl called by class XLite\View\TopCategories

I have tried using both:
Code:
\XLite\Core\Layout::getInstance()->removeTemplateFromLists('categories/list/body.tpl'); \XLite\Core\Layout::getInstance()->removeClassFromLists( '\XLite\View\TopCategories' );
In my XLite\Module\Baby\DropDown\Main.php, but neither work.

This is due to the class being reassigned to the list by the QSL/WatchWorld module/skin.
In XLite\Module\QSL\WatchWorld\Main.php there is this code:
Code:
\XLite\Core\Layout::getInstance()->addClassToList( 'XLite\View\TopCategories', 'layout.header.bar', array( 'zone' => \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'weight' => 140, ) );

I believe this code is overriding the removeClassFromLists function call in my class. It takes precedence I believe because QSL comes alphabetically after Baby.
To overcome this, I tried decorating \XLite\View\TopCategories and adding this code:
Code:
protected function getDir() { return '/modules/Baby/DropDown/menu'; }
Hoping that it would simply use my template instead. But this causes an error because functions called in my template like getMenu()
Are not relative to the TopCategories Class.

So I overcame it by setting the getDir() function of my decorated TopCategories class to
Code:
protected function getDir() { if ($this->getParam(self::PARAM_DISPLAY_MODE) == 'list'){ return '/modules/Baby/DropDown/blank'; } else { return 'categories/' . $this->getParam(self::PARAM_DISPLAY_MODE); } }
And then created a blank body.tpl in that directory.

This feels wrong. I need to go about this in a better way. Perhaps I can use my decorated TopCategories class and just import the module functions from the DropDown class?
Or should I redefine the functions in the TopCategories class? Or is there something else, that would override the QSL module and allow me to remove that class or template?

How would I do this properly, can you provide a code example please?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #2  
Old 08-20-2014, 09:06 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Overriding a skin module with my DropDown Module

I would decorate the TopCategories class and make it display the drop-down list instead of the regular one.

Actually, it can render the drop-down menu already, but is missing necessary CSS files.

So, what you need to make it drop down:

1. Decorate the TopCategories class in your module.

2. In the defineWindgetParams() methods, after executing the parent one, change the value of the static::PARAM_DISPLAY_MODE widget parameter to static:: DISPLAY_MODE_TREE.

3. Add necessary styles through the getCSSFiles() method.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions

Last edited by qualiteam : 08-20-2014 at 09:08 PM.
Reply With Quote

The following user thanks qualiteam for this useful post:
totaltec (08-21-2014)
  #3  
Old 08-22-2014, 02:45 AM
 
JannieB JannieB is offline
 

Senior Member
  
Join Date: Sep 2004
Posts: 117
 

Default Re: Overriding a skin module with my DropDown Module

Hi can you explain this a bit more fully ... I need to do a similar thing...

That is, I want to have a horizontal category menu in the header area, with the ability to show the subcategories in a drop-down type panel.

I have tried using addClassToList in my custom skin main.php to add the topcategories class to the layout.header.bar list and have set up a category menu template there which was getting displayed OK ... but when I try and add code to display the categories I get an error. I am assuming I need to assign the data to the template in some way?

I am also not sure how to get the subcategories available ....

Have only been working on XC5 for a few days, so forgive my ignorance of the new architecture... but any help would be greatly appreciated!

Jan

Jan
__________________
Jan Beesley
(Currently Xcart 5
Previously XCart Gold from 3.5....)
Reply With Quote
  #4  
Old 08-22-2014, 04:56 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Overriding a skin module with my DropDown Module

Hi Jan!

Thank you for the question. I will come to it next week, when I will be preparing an answer for Mike.
Stay tuned!

Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote

The following user thanks tony_sologubov for this useful post:
totaltec (08-22-2014)
  #5  
Old 08-27-2014, 06:10 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Overriding a skin module with my DropDown Module

Hi Mike!

I am not sure whether qualiteam's solution works for you, although it is quite good, but if you want to get rid of TopCategories viewer at all, you can decorate it and redefine its isVisible() method, so it would return false. Once you do this, the categories block will go away.

Method isVisible() exists in every single viewer, so it is pretty easy to get rid of any of them.

If you need to decorate the class after certain module, you can use the approach described here:
http://kb.x-cart.com/pages/viewpage.action?pageId=7504837#Webinar2-10Apr2014-DesignchangesinX-Cart5(Custom...thmyownme nu?

Look at point 7 there.

@Jan
Again, please have a look at the real working example here: http://kb.x-cart.com/pages/viewpage.action?pageId=7504837#Webinar2-10Apr2014-DesignchangesinX-Cart5(Custom...thmyownme nu?

If you still get an error after applying this solution, please send me what error you are getting.

Again, guys, if there is any other question, just let me know.

Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



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 12:02 PM.

   

 
X-Cart forums © 2001-2020