In my zf2 application i have to show database records in mobile and desktop versions with different criteria and conditions. For mobile version i have used getUserMobileTable()
function and for desktop version it is getUserDesktopTable()
.
for mobile version my action should work as
public function userAction()
{
return new ViewModel(array('rowset' => $this->getUserMobileTable()->select()));
}
for desktop version it action should work as
public function userAction()
{
return new ViewModel(array('rowset' => $this->getUserDesktopTable()->select()));
}
What should be logic to do it? Will i need to use navigator.userAgent
in javascript to detect agent? If so then how? Please help i've no idea about it as i'm new to zend framework.
You can use the Mobile Detect module to detect the user's device.
You could also do your logic in the same action and then select a different template like in this example