Open ashishonmobile opened 3 years ago
Finally, I have found another way to solve this
below is my code ` public function beforeRender(EventInterface $event) { $this->viewBuilder()->setTheme('AdminLTE');
if($this->getRequest()->getHeader('Accept')[0] === 'application/json')
{
$this->viewBuilder()->disableAutoLayout();
}else {
$this->viewBuilder()->setClassName('AdminLTE.AdminLTE');
}
}`
Hope this will help other people to fix the problem.
Regards, Ashish
Finally, I have found another way to solve this
below is my code ` public function beforeRender(EventInterface $event) { $this->viewBuilder()->setTheme('AdminLTE');
if($this->getRequest()->getHeader('Accept')[0] === 'application/json') { $this->viewBuilder()->disableAutoLayout(); }else { $this->viewBuilder()->setClassName('AdminLTE.AdminLTE'); } }`
Hope this will help other people to fix the problem.
Regards, Ashish
Thank you, you saved my day
Hi @ashishonmobile
Did you solve the problem or you need help?
when I try to access the http://localhost:8765/users.json it does not return me the json data
I have below function in AppController public function beforeRender(EventInterface $event) { $this->viewBuilder()->setTheme('AdminLTE'); $this->viewBuilder()->setClassName('AdminLTE.AdminLTE'); }
but If I comment the line ' $this->viewBuilder()->setClassName('AdminLTE.AdminLTE');' I am able to get json data from server.
so It seems the issue is somewhere after setting the ClassName
I wish this could be fixed.
Regards, Ashish