ChrisColeman Posted December 13, 2017 Share Posted December 13, 2017 I was just wondering if there is anything 'built in" to cubecart which detects if user-agent is a mobile (ie. tablet, phone, etc.. ). I can do that my self but that would be pointless if its already present. Many Thanks, Chris Coleman. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted December 13, 2017 Share Posted December 13, 2017 You are best of using CSS media queries to look at the viewport size. However deprecated in the PHP code there is some code to look at the user agent. https://github.com/cubecart/v6/blob/98e2ad3c6fc91a8eb6750cacb391333c234633e8/classes/gui.class.php#L903-L931 Quote Link to comment Share on other sites More sharing options...
ChrisColeman Posted December 13, 2017 Author Share Posted December 13, 2017 Yes I guess, but media queries can give the size but not the platform. There is a 'handheld' media type but thats rarely usefull because the mobile user-agents rarely use it. If for example I wished to change text size on parts of the page but only on handhelds it is difficult using media queries.. Chris. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted December 13, 2017 Share Posted December 13, 2017 6 minutes ago, ChrisColeman said: Yes I guess, but media queries can give the size but not the platform. There is a 'handheld' media type but thats rarely usefull because the mobile user-agents rarely use it. If for example I wished to change text size on parts of the page but only on handhelds it is difficult using media queries.. Chris. That's exactly what media queries are for. The CSS logic can be along the lines of "if screen size is less than X pixels make font size y pixels". Maybe I misunderstood you. Quote Link to comment Share on other sites More sharing options...
ChrisColeman Posted December 19, 2017 Author Share Posted December 19, 2017 On 13/12/2017 at 11:20 PM, Al Brookbanks said: That's exactly what media queries are for. The CSS logic can be along the lines of "if screen size is less than X pixels make font size y pixels". Maybe I misunderstood you. Ok well perhaps that was not a good example, what if I wanted to display a different navigation on handheld devices, nothing to do with the width of the platform just a different 'look & feel' ? Chris. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 19, 2017 Share Posted December 19, 2017 (edited) CubeCart does have the code to detect mobile device's "user agent strings". The regex may not be up to date, but can be easily changed. If CubeCart detects a mobile device, it then checks to see if the current skin (according to a setting in the skin's config.xml file) is 'responsive'. If it is, CubeCart will not switch to using an alternate skin. If 'responsive' is false or not found, CubeCart then asks if there is a "mobile" skin that has been selected. If so, CubeCart uses that skin. In admin, you will need to have installed a skin that is not responsive. You will also need to have installed a "mobile" skin. The skins "Kurouto" and "Mobile" are available in the Marketplace. In CubeCart's admin, Store Settings, Layout tab, select Kurouto as the 'Default front-end skin'. Save. Back at this page, the 'Default front-end mobile skin' selector should now be usable. Choose Mobile. Be sure that 'Disable mobile skin' is not checked. Save. Test by accessing your store with a browser whose user agent string states it is a mobile device. Edited December 19, 2017 by bsmither Quote Link to comment Share on other sites More sharing options...
ChrisColeman Posted December 19, 2017 Author Share Posted December 19, 2017 Yes I think that might just do it ... Oh by the way can i use $_SESSION variables to store variables or does CubeCart have a different methodology? Many Thanks, Chris. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2017 Share Posted December 20, 2017 $_SESSION is wrapped in a Session class. There are various methods to manage session contents. Do not hesitate to ask for details. Quote Link to comment Share on other sites More sharing options...
ChrisColeman Posted December 20, 2017 Author Share Posted December 20, 2017 Ok a simple follow up .. Maybe I have a set of variables for a mobile platform, which I need to send to each HTML page. I would like to be able to pass the $_SESSION data between pages (server side) and normally (?) I would use $_SESSION to do that. Maybe I'll use SMARTY to extract the data and send to the page - infact definately I would use SMARTY so I need to be able to get/set the $_SESSION variable within the plugins/hooks system with which I am familiar. How would I hande the $_SESSION array in CubeCart, I'm guessing that its not so complicated but rather than diving into the CubeCart code and then maybe coming up with the wrong answer would appretiate some 'inside info'. Thank You - No Rush - I'm taking a breather until the New Year. Chris. Quote Link to comment Share on other sites More sharing options...
bsmither Posted December 20, 2017 Share Posted December 20, 2017 The essential methods you would use are has(), get(), and set(). When you are ready, send me a PM and we will take this as deep as you need. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.