News:

Support the VirtueMart project and become a member

Main Menu

Mobile page for shop with Mobile Detect

Started by kratzi, January 21, 2016, 23:31:23 PM

Previous topic - Next topic

kratzi

Hi I am setting up my new shop under J 3.4.8 an VM 3.0.12

Since I could imagine this would be interesting for some others I will describe it more thoroughly.

I was looking for some time for a solution to offer my customers a desktop site and a mobile site under the same domain. I was not very much interested in a responsive template nor in http://domain.com and http://m.domain.com.
Also all available plugins had some issues and I found Mobile Detect "http://mobiledetect.net/" which detects if the user comes with a mobile device or not. There is also a Plugin from Yagendoo which uses this script.

Basically with this bit you can control your code:

<?php
if(MobileDetector::isMobile() === true)

?>


First I was looking for some code howto load a completely different template depending on the device but could not find any solution. Unfortunately my php skills are quite limited so if you would know a code how to control the template to load please let me know.

The only solution which I see at the moment is to control it the following:
For CSS

<?php
if(MobileDetector::isMobile() === false)
{
echo "<link rel='stylesheet' href='templates/template/css/template.css' type='text/css' />";
} else {
echo "<link rel='stylesheet' href='templates/template/css/mobile.css' type='text/css' />";
}
?>


For the <body> of the page in index.php


<?php
if(MobileDetector::isMobile() === false)

include (
"templates/template/template.php");
} else {
include (
"templates/template/mobile.php");
?>




So basically I load two different bodies in the index.php depending on the device.

My question is now if by this solution I could have any disadvantages with my site speed or possible any security issues. This is something I care about most.

Thank you

kratzi

GJC Web Design

I see no reasons for security or load speed concerns

as another variation you could load the css separately and just swap two different parts of the template in the template index.php

why not responsive?  I am happy with my site designs incl. cart at all resolutions and only use responsive techniques..
My worry with mobile detect scripts is they can go out of date very easily where as screen sizes are screen sizes..
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

kratzi

Thanks.

I understand your concerns however as I understood this script is updated regularly at the moment and also is not only detecting the screen size but has a huge list of mobile devices registered.

kratzi

PRO

browser detection etc is standard in joomla

https://www.spiralscripts.co.uk/Joomla-Tips/browser-detection-in-joomla-3.html
https://api.joomla.org/cms-3/classes/JBrowser.html

&&   unless you are a very large company like wal mart, staples etc. which can overcome google problems easier. I would go with responsive design.


Spiros Petrakis

Hi kratzi,

i use this script in my templates and they have several thousands installations with no issues reported so far , just make sure to update it when needed.
Joomla templates and extensions development
https://www.yourgeek.gr