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)
-   -   Make Sidebar Item only show on the home page. (https://forum.x-cart.com/showthread.php?t=70246)

Phil Richman 10-14-2014 11:54 AM

Make Sidebar Item only show on the home page.
 
I created a simple mod for xcart 5 that adds a menu item to the sidebar called Quick Links. Everything works fine with the mod. It shows up in the side bar just like it is supposed to, but I want it to only show on the home page. Where as now it shows on every page with the sidebar. What is the easiest way to accomplish this?


Below is my QuickLinks.php


<?php

namespace XLite\Module\Pmall\QuickLinks\View;

/**
* @ListChild (list="sidebar.first", zone="customer", weight="101")
*/

class QuickLinks extends \XLite\View\SideBarBox
{
protected function getHead()
{
return 'Quick Links';
}


protected function getDir()
{
return 'modules/Pmall/QuickLinks/menu';
}
}

tony_sologubov 10-14-2014 12:29 PM

Re: Make Sidebar Item only show on the home page.
 
In your QuickLinks class add method isVisible() like this:

PHP Code:

protected function isVisible()
    {
        return 
parent::isVisible()
            && \
XLite\Core\Request::getInstance()->target == 'main';
    } 


and it should do the trick.

Tony

Phil Richman 10-14-2014 12:43 PM

Re: Make Sidebar Item only show on the home page.
 
Thank you very much. That worked.


All times are GMT -8. The time now is 08:48 AM.

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