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