X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Modifying the design and features (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Wordpress in XC 5 ... remove "Blog" from Top Menu (https://forum.x-cart.com/showthread.php?t=70172)

JannieB 10-07-2014 06:11 AM

Wordpress in XC 5 ... remove "Blog" from Top Menu
 
I have just installed Wordpress extension for XC5 ... all good so far ... as well as a blog I want to use it as a page editor ... a lot easier to set up custom page templates etc ...(more on that story later ...)

... anyway ..

The extension automatically adds "Blog" to the main (ie. top) menu ... I don't want this - how do I stop it??

Thanks,

Jan

JannieB 10-07-2014 07:52 AM

Re: Wordpress in XC 5 ... remove "Blog" from Top Menu
 
In answer to my own question I sorted it like this:

I added a new class in my custom skin as follows:
Code:

abstract class TopMenu extends \XLite\View\Menu\Customer\Top implements \XLite\Base\IDecorator
{
  /**
    * Define items
    *
    * @return array
    */
    protected function defineItems() {
               
        $items = parent::defineItems();
                $aNew = array();
               
                foreach ($items as $aItem) {
                        if ($aItem['label'] != static::t('Blog') ) {
                                $aNew[] = $aItem;
                        }
                }
        return $aNew;
    }
}


A slightly rubbish way of doing it, but it worked!

cflsystems 10-07-2014 08:17 AM

Re: Wordpress in XC 5 ... remove "Blog" from Top Menu
 
You can just do ... instead of looping through the array and creating new one

PHP Code:

protected function defineItems()
{
    
$items parent::defineItems();
        
        foreach (
$items as $aItem) {
        if (
$aItem['label'] == static::t('Blog')) {
            unset(
$items[$aItem]);
            break;
        }
        }
    
    
// if the array is just a contiguous numeric array you
    // may want to renumber it before the return 
    // array_values($array)
    
return $items;




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

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