Not a bug Can't set params with CEL!

vbresults

Well-known member
library/Foo/Listener.php
PHP:
    public static function loadClassView($class, array &$extend) {
        if ($class == 'XenForo_ViewPublic_Forum_List') {
            $extend[] = 'Foo_ViewPublic_Forum_List';
        }
    }
library/Foo/ViewPublic/Forum/List.php
PHP:
class Foo_ViewPublic_Forum_List extends XFCP_Foo_ViewPublic_Forum_List {
    public function prepareParams() {
        parent::prepareParams();
        $this->setParams(array('foo' => 'bar'));
    }
}
library/Foo/Listener.php
PHP:
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template) {
        $params = $template->getParams();
        if ($hookName == 'page_container_sidebar') {
            // Outputs string(29) "XenForo_ViewPublic_Forum_List", NULL
            var_dump($params['viewName'], $params['foo']);
        }
    }
I have tried several permutations (switching parent : : prepareParams() and setParams, extending XenForo_View and XenForo_ViewPublic_Base) but none of them work.
 

Mike

XenForo developer
Staff member
You're overriding the view for the forum list page, but based on your template hook, it looks like you're trying to use a param you exposed to forum_list in PAGE_CONTAINER. "Inner" view params aren't exposed to the container. You can set container params in the controller response though.
 
Top