Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Different resolution - different page


Guest

Recommended Posts

This is more like psuedo code. It is in /catalog/index.php. Trying to get that javascript to detect resolution and make this php include command go to the proper page based on the info.

 

 

<?php

<script language="Javascript1.2">

<!--

 

if (screen.width <= 800) {

document.location.href = "h800.php";

}

 

if (screen.width <= 1024) {

document.location.href = "h1024.php";

}

 

else if (screen.width >= 1152) {

document.location = "h1152.php";

}

 

else if (screen.width >= 1280) {

document.location.href = "h1280.php";

}

 

else if (screen.width >= 1600) {

document.location.href = "h1600.php";

}

 

//-->

</script>

 

<form name=res>

<input type=hidden value=document.location.href>

</form>

 

<!-- header //-->

<?php require(DIR_WS_INCLUDES . 'echo('res');'); ?>

<!-- header_eof //

 

 

?>

Link to comment
Share on other sites

I tried this also based on reading the forums. It said cannot find file. Very wierd.

 

// Resolution redirect (on top of index.php in main dir)

if (!$spider_flag) {

if ((isset($HTTP_GET_VARS['x'])) and (!tep_session_is_registered('res'))) {

if ($HTTP_GET_VARS['x'] == '1') {

$res = '800';

} elseif ($HTTP_GET_VARS['x'] == '2') {

$res = '1024';

}elseif ($HTTP_GET_VARS['x'] == '3') {

$res = '1152';

}elseif ($HTTP_GET_VARS['x'] == '4') {

$res = '1280';

}elseif ($HTTP_GET_VARS['x'] == '5') {

$res = '1600';

} else {

$res = '800';

}

if (!tep_session_is_registered('res')) {

tep_session_register(res);

}

} else {

if ($HTTP_GET_VARS) {

if (!tep_session_is_registered('res')) {

echo '<script>';

echo 'if (screen.width==800) {location.href=self.location.href+"&x=1" }';

echo 'if (screen.width==1024) {location.href=self.location.href+"&x=2" }';

echo 'if (screen.width==1152) {location.href=self.location.href+"&x=3" }';

echo 'if (screen.width==1280) {location.href=self.location.href+"&x=4" }';

echo 'if (screen.width==1600) {location.href=self.location.href+"&x=5" }';

echo '</SCRIPT>';

echo '<noscript>';

echo '</noscript>';

echo "\n";

}

} else {

if (!tep_session_is_registered('res')) {

echo '<script>';

echo 'if (screen.width==800) { location.href=self.location.href+"?x=1" }';

echo 'if (screen.width==1024) { location.href=self.location.href+"?x=2" }';

echo 'if (screen.width==1152) { location.href=self.location.href+"?x=3" }';

echo 'if (screen.width==1280) { location.href=self.location.href+"?x=4" }';

echo 'if (screen.width==1600) { location.href=self.location.href+"?x=5" }';

echo '</SCRIPT>';

echo '<noscript>';

echo '</noscript>';

echo "\n";

}

}

}

}

 

Below is also in index, the header code. the h800, h1024, etc files are in includes. I tried also giving it a path like includes/h800. still cannot find file

 

<!-- header //-->

if ($_SESSION['res'] == '800') {

define('resol', 'h800.php');

} elseif ($_SESSION['res'] == '1024') {

define('resol', 'h1024.php');

} elseif ($_SESSION['res'] == '1152') {

define('resol', 'h1152.php');

}elseif ($_SESSION['res'] == '1280') {

define('resol', 'h1280.php');

}elseif ($_SESSION['res'] == '1600') {

define('resol', 'h1600.php');

} else {

define('resol', 'h800.php');

}

<?php require(DIR_WS_INCLUDES . $resol); ?>

<!-- header_eof //-->

?>

Link to comment
Share on other sites

here are the errors

 

if ($_SESSION['res'] == '800') { define('resol', 'includes/h800.php'); } elseif ($_SESSION['res'] == '1024') { define('resol', 'includes/h1024.php'); } elseif ($_SESSION['res'] == '1152') { define('resol', 'includes/h1152.php'); }elseif ($_SESSION['res'] == '1280') { define('resol', 'includes/h1280.php'); }elseif ($_SESSION['res'] == '1600') { define('resol', 'includes/h1600.php'); } else { define('resol', 'includes/h800.php'); }

Warning: main(includes/): failed to open stream: No such file or directory in /home/billeta/public_html/shoppingcart/index.php on line 107

 

Warning: main(includes/): failed to open stream: No such file or directory in /home/billeta/public_html/shoppingcart/index.php on line 107

 

Fatal error: main(): Failed opening required 'includes/' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/billeta/public_html/shoppingcart/index.php on line 107

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...