php - Symfony2 Load content based on device used with LiipThemeBundle -
i need make controller load different skin information based on device being used with. can load templates liipbundle. wonder if can load content too?? example controller:
public function mainaction() { $em = $this->getdoctrine()->getmanager(); $skins = $em->getrepository('mediaparkltskinbundle:skin')->findoneby( array('id' => 1)); return $this->render('mediaparkltmainbundle:main:main.html.twig', array('skin' => $skins)); return array(); }
right loads skin id 1 on theme. need make if statement , check if user on desktop, if load theme skin... how can that??? here idea:
public function mainaction() { (if using desktop) { $em = $this->getdoctrine()->getmanager(); $skins = $em->getrepository('mediaparkltskinbundle:skin')->findoneby( array('id' => 1)); return $this->render('mediaparkltmainbundle:main:main.html.twig', array('skin' => $skins)); } else { $em = $this->getdoctrine()->getmanager(); $skins = $em->getrepository('mediaparkltskinbundle:skin')->findoneby( array('id' => 2)); return $this->render('mediaparkltmainbundle:phone:phonemain.html.twig', array('skin' => $skins)); } return array(); }
how can make happen?
inspect user agent see if there indications of mobile. or search library this.
see $_server['http_user_agent']
Comments
Post a Comment