September 27, 20188 yr Dear, I am try to override the RenderView() function from adminOrdersController, without copy all function. I am try to add only some tplviewvars, but dont have success, i think is a little detail but don't find it. Have any idea? public function renderView() { parent::renderView(); $extra_var = [ 'dados_comment_order' => 5555, 'dados_garantia' => 'asdfasf' ]; array_push($this->tpl_view_vars, $extra_var); return parent::renderView(); }
September 27, 20188 yr Author Solved! ``` public function initContent(){ parent::initContent(); } public function renderView() { parent::renderView(); $this->tpl_view_vars['dados_garantia'] = '654654654'; return AdminController::renderView(); } ```
September 27, 20188 yr Glad to see you got it solved! public function initContent(){ parent::initContent(); } This should be a no-op. You can remove it entirely without a change in behavior. public function renderView() { parent::renderView(); $this->tpl_view_vars['dados_garantia'] = '654654654'; return AdminController::renderView(); } Here you call renderView() twice. This should be faster and give the same results: ``` public function renderView() { $this->tplviewvars['dados_garantia'] = '654654654'; return parent::renderView(); } ```
September 27, 20188 yr Author @traumflug said in Override RenderView(): public function renderView() { $this->tplviewvars['dados_garantia'] = '654654654'; return parent::renderView(); } I try here and don't work. I dont know why. Only work with my solution.
September 27, 20188 yr What is not working? Do you get any error or is the variable just not accessible? How does your override class look like?
September 28, 20188 yr Author @wakabayashi not work if i use the @Traumflug suggestion. I need use all public function renderView() { parent::renderView(); $this->tpl_view_vars['dados_garantia'] = '654654654'; return AdminController::renderView(); }
September 28, 20188 yr @mauroagr Ah yeah I think I see the problem: @Traumflug doesn't the $this->tplviewvars just get overriden, when you call parent::renderView()?
September 28, 20188 yr doesn’t the $this->tplviewvars just get overriden, when you call parent::renderView()? That's apparently the case. Overridden by the class between the override and AdminController.
Create an account or sign in to comment