1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Not a Bug Can't set params with CEL!

Discussion in 'Resolved Bug Reports' started by vbresults, Nov 10, 2011.

  1. vbresults

    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 $hookParamsXenForo_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.
     
  2. Mike

    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.
     
    LancerForHire likes this.

Share This Page