Thread: Edit Lists?
View Single Post
  #2  
Old 03-24-2015, 06:25 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

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

Default Re: Edit Lists?

You assign things to the list, and take them away.
Templates can assign themselves to lists, and so can PHP classes.

Here is a class adding itself to a list:
* @ListChild (list="center", zone="customer")

And a template:
* @ListChild (list="capost_create_return.form.columns", weight="15")

In both cases you will see these declarations in the commented out section at the top of the file. I prefer to add templates/classes to lists by decorating the class or overriding the original template.

You can also do a lot of heavy lifting right in your main.php file.

To add a class or a template to a list, you wrap the call to the addClassToList() method in a function called runBuildCacheHandler() like this:
Code:
public static function runBuildCacheHandler() { parent::runBuildCacheHandler(); \XLite\Core\Layout::getInstance()->addClassToList( 'XLite\Module\CDev\Bestsellers\View\Bestsellers', 'sidebar.second', array( 'zone' => \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'weight' => 100, ) ); \XLite\Core\Layout::getInstance()->addTemplateToList( 'modules/CDev/XMLSitemap/menu.tpl', 'sidebar.second', array( 'zone' => \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'weight' => 100, ) ); }

You can remove a class from a list, and remove a template from a list in your main.php like this:
Code:
/** * Decorator run this method at the end of cache rebuild * * @return void */ public static function runBuildCacheHandler() { parent::runBuildCacheHandler(); \XLite\Core\Layout::getInstance()->removeClassFromList( 'XLite\View\LanguageSelector\Customer', 'layout.header.bar.links.newby', \XLite\Model\ViewList::INTERFACE_CUSTOMER ); \XLite\Core\Layout::getInstance()->removeTemplateFromLists( 'layout/main.location.tpl' ); }

You can move classes in lists:
Code:
protected static function moveClassesInLists() { return array( 'XLite\View\LanguageSelector\Customer' => array( array('layout.header.bar.links.logged', 'customer'), array('layout.header.magnifico.top.bar', 50, 'customer'), ), ); }

Move templates in lists:
Code:
protected static function moveTemplatesInLists() { $templates_list = array(); $templates_list = array( 'layout/header.bar.search.tpl' => array( array('layout.header.bar', 'customer'), array('layout.header.bar', 30, 'customer'), ), 'layout/header.right.tpl' => array( array('layout.header', 'customer'), array('layout.header', 350, 'customer'), ), ); return $templates_list; }

I took most of these examples from my Magnifico template, but you can see where I originally learned them in XLite\Core\Layout.php
__________________
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