Magento Design Exceptions – How to Switch Back to Desktop

controllersmagento-enterprisemobiletheme

I am using Magento's design exceptions to set the theme as mobile for mobile devices.

enter image description here

Since I am not using a separate store view or website, is it possible to provide to the user a 'Switch to Desktop' link? I guess I would need to override a controller somewhere, would appreciate anyone that can help me out with a starting point.

Best Answer

The short answer here is no, though, you could drop a javascript cookie called forcedesktop and set it to true. This would be set onclick for the switcher link.

Then rewrite the design exception method to sniff for existence of the cookie:

app/code/local/YourCompany/YourModule/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <YourCompany_YourModule>
             <version>0.1.0</version>
        </YourCompany_YourModule>
    </modules>
    <global>
        <models>
            <core>
                <rewrite>
                    <design_package>YourCompany_YourModule_Model_Design_Package</design_package>
                </rewrite>
            </core>
        </models>
    </global>
</config>

app/code/local/YourCompany/YourModule/Model/Design/Package.php

<?php

class YourCompany_YourModule_Model_Design_Package extends Mage_Core_Model_Design_Package
{

    protected function _checkUserAgentAgainstRegexps($regexpsConfigPath)
    {
        if(Mage::getModel('core/cookie')->get('forcedesktop')=='true'){
            return false;
        }

        parent::_checkUserAgentAgainstRegexps($regexpsConfigPath);
    }
}
Related Topic