Joomla switch template if screen resoluton > 1024*768

2.1k views Asked by At

I need to change template if screen resolution is bigger than 1024*768 pixel. I try Meta Template 1.8. It has many tools to the template change, but it doesn't have resolution tool. I know that I need to do without Joomla: query the resolution in javascript, then set a new location with a GET param.
But I don't know how can I do this in Joomla..

Please give me any advice. Sorry for my bad english..

3

There are 3 answers

0
fornve On

Use JRequest::getInt('res') instead of $_GET['res'].

JRequest::getInt('res') will look into $_GET & $_POST

Have a look in JRequest spec

0
user594297 On

I solved my problem: To the default template's index.php I add this rows at the top of the file:

<? if(!isset($_GET['res']) ) : ?>
<script language="javascript">
window.location.href = "index.php?res=" + screen.width;
</script> 
<? endif; ?>

And I add this row to the Meta Template / Rules / Advenced Php:

if($_GET['res']>1024)
return "mytemplatename";

I work with the GET array, so my url will be a little mess.

How can I do this with the POST array?

0
Jeepstone On

You should perhaps look at keeping a single template and then using something like http://stuffandnonsense.co.uk/projects/320andup/ to handle resizing based on the screen size.