EDIT
This is the full code of the plugin. I have not included the helper as this is just a mass list of all agents for lookups.
<?php /** * @package CMMobileDetection plugin * @copyright Copyright (C) 2012-2013 CMExtension Team http://www.cmext.vn/ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL */
// No direct access defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
require_once 'helper.php';
class plgSystemCMMobileDetection extends JPlugin {
public function onAfterInitialise()
{
if(JPATH_BASE != JPATH_ADMINISTRATOR)
{
$browser = new Mobile_Detect();
$mobileCookie = JFactory::getApplication()->input->cookie->get('cmmobileRequestDesktop',
-1, 'int');
$component = JRequest::getVar('option');
if(($browser->isMobile() || $browser->isTablet()) && ($mobileCookie == 0 || $mobileCookie == -1) && $component == 'com_cmgroupbuying')
{
$configuration = $this->getConfiguration();
$db = JFactory::getDBO();
$query = "SELECT params FROM #__template_styles WHERE client_id = 0 AND template = ".$db->Quote($configuration['mobile_template'])." ORDER BY id LIMIT 1";
$db->setQuery($query);
$params = $db->loadResult();
if(empty($params))
$params = '{}';
JFactory::getApplication()->setTemplate($configuration['mobile_template'], $params);
}
}
}
public function getConfiguration()
{
$db = JFactory::getDBO();
$query = 'SELECT * FROM #__cmgroupbuying_configuration WHERE id = 1';
$db->setQuery($query);
$configuration = $db->loadAssoc();
if($db->getErrorNum())
{
//JError::raiseError(500, implode('<br />', $errors));
return false;
}
return $configuration;
} } ?>
This does include my alteration, which basically has one function, stop the plugin loading on ANY page that is NOT using option=com_cmgroupbuying as it interferes with the mobile template of all the other pages. As already stated, this works beautifully when SEF is turned off.