mauroagr Posted September 27, 2018 Share Posted September 27, 2018 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(); } Link to comment Share on other sites More sharing options...
mauroagr Posted September 27, 2018 Author Share Posted September 27, 2018 Solved! ``` public function initContent(){ parent::initContent(); } public function renderView() { parent::renderView(); $this->tpl_view_vars['dados_garantia'] = '654654654'; return AdminController::renderView(); } ``` Link to comment Share on other sites More sharing options...
Traumflug Posted September 27, 2018 Share Posted September 27, 2018 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(); } ``` Link to comment Share on other sites More sharing options...
mauroagr Posted September 27, 2018 Author Share Posted September 27, 2018 @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. Link to comment Share on other sites More sharing options...
wakabayashi Posted September 27, 2018 Share Posted September 27, 2018 What is not working? Do you get any error or is the variable just not accessible? How does your override class look like? Link to comment Share on other sites More sharing options...
mauroagr Posted September 28, 2018 Author Share Posted September 28, 2018 @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(); } Link to comment Share on other sites More sharing options...
wakabayashi Posted September 28, 2018 Share Posted September 28, 2018 @mauroagr Ah yeah I think I see the problem: @Traumflug doesn't the $this->tplviewvars just get overriden, when you call parent::renderView()? Link to comment Share on other sites More sharing options...
Traumflug Posted September 28, 2018 Share Posted September 28, 2018 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now