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)
-   -   Removing/Editing the Primary Menu (Solved) (https://forum.x-cart.com/showthread.php?t=69018)

totaltec 04-12-2014 12:46 PM

Removing/Editing the Primary Menu (Solved)
 
Previously I was discussing this problem in this thread:http://forum.x-cart.com/showthread.php?t=69010

What we are trying to accomplish is remove and edit the top menu also known in the CDev\SimpleCMS modules as the Primary Menu. I struggled with this for a while, and realized there were several teaching points here that I could use to help others.
Removing the Primary Menu: So without further ado I reveal the second of my tutorials on X-cart 5: http://youtu.be/byLG9q13pxk

You can find all of my X-cart 5 tutorials here: http://forum.x-cart.com/showthread.php?t=64668

totaltec 04-13-2014 09:06 AM

Re: Removing/Editing the Primary Menu (Solved)
 
So what was needed is to remove the top menu so I could add my own, I believe it would be normally accomplished by extending the class
XLite\View\Menu\Customer\Top

In this case though, the module CDev\SimpleCMS already extended this class. As of now, I don't know a way to extend another modules extension. Since CDev came after Baby (my company id) alphabetically, then its changes were overwriting my own when I tried to extend the class.

First I tried removing the template top_menu.tpl by using the function removeTemplateFromLists contained in XLite\Core\Layout.php, but found it was not included in the "template lists". Instead I ultimately used this code in my Baby\DropDown\Main.php file:
Code:

    public static function runBuildCacheHandler()
    {
        parent::runBuildCacheHandler();

      \XLite\Core\Layout::getInstance()->removeClassFromLists(
          'XLite\View\Menu\Customer\Top'
      );
   
    }

This unset the viewer class that was calling the template completely. My next move is to include my new template with my code to display the menu.

Any suggestions or comments welcome! Please let me now if I am doing this wrong or right.

-Mike

xplorer 04-16-2014 11:02 PM

Re: Removing/Editing the Primary Menu (Solved)
 
If you want to wipe the menu completely and replace it with your custom one, you can make the \XLite\View\Menu\Customer\Top::isVisible() return FALSE (so that the widget won't show up on the page at all), and add a new custom widget having @ListChild (list="layout.main", weight="250") in its declarations.

totaltec 04-16-2014 11:38 PM

Re: Removing/Editing the Primary Menu (Solved)
 
Slava,
Thanks!
Anything wrong with the way I did it?

xplorer 04-17-2014 12:06 AM

Re: Removing/Editing the Primary Menu (Solved)
 
The way you did it will work (and, I guess, it will be a bit better in terms of the performance). However, runBuildCacheHandler() is not the place that you look into when investigating why the menu is not displayed on the page :-) Your way may be confusing for other developers customizing your code later.


All times are GMT -8. The time now is 01:05 PM.

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