4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Requests & Discussions) => Topic started by: nameless on May 11, 2015, 05:24:36 AM
-
Hello
How Can i make phone browser switch
I have my site
www.mysite.com
and i made a mobile ver
www.mysite.com/mobile
how can i make phone browser switch
when u enter the site from a phone this www.mysite.com/mobile work
when u enter the site from a computer this www.mysite.com work
i found this but i do 't understant any thing from it
http://www.4homepages.de/forum/index.php?topic=30818.0
thanks for all ur help
-
Hi!
1.) Create a new Folder ../templates/mobile
2.) search in global.php:
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
insert above:
$agent = array(
"Android",
"webOS",
"iPhone",
"iPod",
"Android",
"Blackberry",
"OperaMobi",
"Opera Mini",
"IEMobile",
"Jasmine",
"Fennec",
"Blazer",
"Minimo",
"MOT-",
"Nokia",
"SAMSUNG",
"Polaris",
"LG-",
"SonyEricsson",
"SIE-",
"AUDIOVOX",
"mobile",
);
foreach($agent AS $name){
if( strstr($_SERVER['HTTP_USER_AGENT'],$name)){
$config['template_dir'] = "mobile";
}else{
$config['template_dir'] = $config['template_dir'];
}
}
Now create a new template only for mobile Devices in the new Folder "mobile".
mfg Andi
-
thanks Rembrandt for ur replay
It work but we have some problem when i make the mobile ver. just a template in the original site
so we have to make the mobile ver. a new copy with the same database but defrant in the setting table
and i make all this
My original site is www.domain.com
the mobile ver. is www.domain.com/mobile
so how can i switch between the too sites
look at this site he make it but i do't know how
http://www.mps-fotos.de/4images/
http://www.mps-fotos.de/mobile/
thanks
-
search in the code:
foreach($agent AS $name){
if( strstr($_SERVER['HTTP_USER_AGENT'],$name)){
$config['template_dir'] = "mobile";
}else{
$config['template_dir'] = $config['template_dir'];
}
}
and replace:
foreach($agent AS $name){
if( strstr($_SERVER['HTTP_USER_AGENT'],$name)){
header('Location: http://www.domain.com/mobile');
}
}
-
thanks thanks thanks Rembrandt
i make it and work great
But still one problem
----------------------------
in the mobile ver. i need to make a link (View this site in Normal view)
like this site
http://www.mps-fotos.de/mobile/
the link in the end of the page
Diese Seite in der Normalansicht ansehen.
thanks againe
-
Will some one help me
in the mobile ver. i need to make a link (View this site in Normal view) to play the normal site on the mobile
like this site
http://www.mps-fotos.de/mobile/
the link in the end of the page
Diese Seite in der Normalansicht ansehen.
i found this but i do 't understant any thing from it
http://www.4homepages.de/forum/index.php?topic=30818.0
-
On the mobile site you need to insert:
<a href="../4images/<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
where the Links should be shown.
On desktop-page you need to insert:
<a href="../mobile/<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
where the Links should be shown.
You need to change /4images/ and /mobile/ with your subfolder-names.
-
Thanks Scarala for ur help
<a href="../<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
i try it but it did not work at the mobile but it work at my computer
i mean when i run the mobile site from my computer and i use to see the desktop pape it work
but when i run the mobile site from my mobile and i use to see the desktop pape it did't work
I hope u can find why it did not work
thanks agane
-
This is really difficult for me to explain...
<a href="../<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
Your Desktop-Page has to be in an Subfolder too.
Otherwise the Script from Rembrandt will redirect you automaticaly to mobile page.
In Root folder i have following index.php-File:
<head>
<title>You Sitename</title>
<?php
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Android') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'OperaMobi') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'IEMobile') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Jasmine') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Fennec') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Blazer') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Minimo') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'MOT-') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Nokia') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'SAMSUNG') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'Polaris') ||
strstr($_SERVER['HTTP_USER_AGENT'], 'LG-'))
{
echo '<script type="text/javascript">';
echo 'window.location.href = "mobile";';
echo '</script>';
}
?>
<meta http-equiv="refresh" content="0; URL=4images">
</head>
So if itīs a Mobile Client the User is redirected to subfolder /mobile
If itīs a Desktop Client the User is redirected to subfolder /4images
And then you neet to change
<a href="../<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
to
<a href="../4images/<?php echo basename($_SERVER[SCRIPT_NAME]) . '?' . $_SERVER['QUERY_STRING']; ?>" target="_self">Open desktop page.</a>
Voila, everything will work fine ;-)