nikola Posted December 17, 2011 Share Posted December 17, 2011 I've seen the other thread about making the mobile version of the site, but maybe I have a different scenario. Let's say I have a normal site and it's complete structure is tied to pw templates. I want to add a code (php) that will detect if user is viewing the site with mobile phone and it would redirect them to mobile version of the site. But mobile version of the site would use separate head.inc, foot.inc and custom templates to show the data. How can I use data from fields that are used in normal site templates in templates specific for the mobile version of the site. The mobile version of the site is not adopting it's design to the mobile phone, rather it's a new design with it's own set of templates. I want to avoid duplicating the content for the mobile site, as it would be time consuming for the editor. Link to comment Share on other sites More sharing options...
Marty Walker Posted December 17, 2011 Share Posted December 17, 2011 Hi Nikola, I use this to detect what device a user is coming from: http://code.google.com/p/php-mobile-detect/ Then in your templates: <?php if ($detect->isMobile()) { include ('./mobile-specific-template.inc'); } eg: If it was for navigation you could do this: <?php if ($detect->isMobile()) { include ('./nav-mobile.inc'); } else { include('./nav-desktop.inc'); } Regards Martin Link to comment Share on other sites More sharing options...
nikola Posted December 18, 2011 Author Share Posted December 18, 2011 Thanks for the script. My concerns are following: If I use one template for the normal site and the other one for mobile version of the site, I can't select multiple templates per page in admin. I want to use one template that holds information such as title, summary, body, images and so on so that user only has to update or edit one page in the admin, and on the front end it will split up based on device detection (using two separate templates). For instance: Let's say we have page "About us" that has it's own html/css layout for normal viewing and separate html/css for mobile viewing. I need to make two different templates. I would create page in admin called "About us", link it to "selector template" that would contain code like: <?php if ($detect->isMobile()) { include ('./about-mobile.inc'); } else { include('./about.inc'); } so the visitors can be redirected to detected version of the site. I could populate "selector" template (for instance "about-selector.php") with fields I want, and then pull them directly in this two separate templates, like: <?php echo $pages->find("template=about-selector")->title ?>, <?php echo $pages->find("template=about-selector")->body ?> , ... This way I would only need to create/edit one page in admin and pull the content within two separate templates. Is there any way of simplifying this procedure? 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