pegasus
Well-known member
Currently there are 3 ways to modify the sidebar:
1. Pass to container as controller->responseView(..., ..., ..., $containerParams_with_Sidebar_key)
2. Set local $__extraData in template_post_render for PAGE_CONTAINER ($containerData in a listener)
3. XenForo_Template_Public::_mergeExtraContainerData(array('sidebar' => $html))
There are inherent problems with these methods.
First, every add-on must know to check all 3 for existing modifications in order to avoid breaking them. Even popular mods like [bd] Widget Framework currently don't check all 3.
More importantly, if method #3 or #2 is used by a different mod, XenForo internally overwrites sidebar changes made by method #1.
This could easily be avoided by including even a rudimentary Sidebar factory in the XenForo core. e.g.
1. Pass to container as controller->responseView(..., ..., ..., $containerParams_with_Sidebar_key)
2. Set local $__extraData in template_post_render for PAGE_CONTAINER ($containerData in a listener)
3. XenForo_Template_Public::_mergeExtraContainerData(array('sidebar' => $html))
There are inherent problems with these methods.
First, every add-on must know to check all 3 for existing modifications in order to avoid breaking them. Even popular mods like [bd] Widget Framework currently don't check all 3.
More importantly, if method #3 or #2 is used by a different mod, XenForo internally overwrites sidebar changes made by method #1.
This could easily be avoided by including even a rudimentary Sidebar factory in the XenForo core. e.g.
Code:
class XenForo_Helper_Sidebar
{
protected static $sidebar = array();
public static function push($html)
{
self::$sidebar[] = $html;
}
/* for internally populating PAGE_CONTAINER $sidebar */
public static function getHtml()
{
return implode('', self::$sidebar);
}
}