Created
June 28, 2012 18:12
-
-
Save drmmr763/3013000 to your computer and use it in GitHub Desktop.
Set cookie attempt for forcing mobile views.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// In Mobile template index.php | |
// get the form value and change the cookie based on that | |
$fullsite = JRequest::getVar('fullsite'); | |
// if we want the full view forced set the cookie | |
if($fullsite == 1) { | |
setcookie("fullsite", $fullsite, time() + 3600); | |
} | |
elseif ($fullsite == 0) { | |
setcookie("fullsite", $fullsite, time() - 3600); | |
} | |
?> | |
<!-- HTML For the index.php mobile template. little form to set the value --> | |
<!-- SET hidden value to 0 in regular template to reverse this --> | |
<form method="post" target="index.php"> | |
<input name="fullsite" type="hidden" value="1" /> | |
<input type="submit" value="Full Site" /> | |
</form> | |
<!-- | |
---- MODIFICATIONS TO THE SH404 template switch plugin | |
---- DO NOT TRY THIS AT HOME | |
--> | |
<?php | |
public function onAfterRoute() { | |
// change the isMobile if statement: | |
if ( $isMobile ) { | |
if ($_COOKIE['fullsite')) { | |
// set the full template. | |
$this->_setTemplate( "ja_t3_blank"); | |
} | |
if(!$_COOKIE['fullsite') { | |
// no cookie or the cookie is set to 0, so load the mobile | |
$template = $this->params->get('mobile_template', ''); | |
$this->_setTemplate( $template); | |
} | |
}// isMobile | |
}// close func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment