• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC How to create landing page for mobile browser?

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,576
Solutions
28
Reaction score
898
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I have a big question. How can I redirect people who visit my website via mobile, to some kind of landing page, or mobile.php. So they're only be allowed to see that part of the website (I tried to fit the layout, but considering how it is built, I think that sending another page is a much better idea to don't screw the layout).

Looking for some kind of "if user === mobile, then... blablabla.php".

I use ZnoteAAC and UniformServer. Any help is very appreciated!
Thanks in advancd!
 
Solution
Lua:
<?php
// Check if the user agent indicates a mobile device
function isMobileDevice() {
    return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $_SERVER['HTTP_USER_AGENT']);
}

// If the user is using a mobile device, redirect them to mobile.php
if (isMobileDevice()) {
    header("Location: mobile.php");
    exit();
}
?>
Lua:
<?php
// Check if the user agent indicates a mobile device
function isMobileDevice() {
    return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $_SERVER['HTTP_USER_AGENT']);
}

// If the user is using a mobile device, redirect them to mobile.php
if (isMobileDevice()) {
    header("Location: mobile.php");
    exit();
}
?>
 
Solution
I think the only option you have is to calculate the resolution size of the device using javascript, if it is less than a threshold it could mean that he is using his mobile and then you can choose to redirect him to another page

Maybe there is some other dirty trick, but I don't know.
 
Lua:
<?php
// Check if the user agent indicates a mobile device
function isMobileDevice() {
    return preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $_SERVER['HTTP_USER_AGENT']);
}

// If the user is using a mobile device, redirect them to mobile.php
if (isMobileDevice()) {
    header("Location: mobile.php");
    exit();
}
?>
Worked so good man! Thanks a lot hahaha :p
 
 
As El Bringy suggested, checking the User Agent is by far one of the best methods to detect a mobile device, but this should only really be used server side.

We are not in 2005 anymore... for front-end, I would strongly suggest using media queries in CSS for viewport breakpoints:
W3Schools online HTML editor (https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_mq_breakpoints)

The above link is a basic overview of how it is done. You can message me privately if you want any more info.
 
As El Bringy suggested, checking the User Agent is by far one of the best methods to detect a mobile device, but this should only really be used server side.

We are not in 2005 anymore... for front-end, I would strongly suggest using media queries in CSS for viewport breakpoints:
W3Schools online HTML editor (https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_mq_breakpoints)

The above link is a basic overview of how it is done. You can message me privately if you want any more info.
Thanks for this! I litterally started to thing on making a header for each page, using the redirection. I'm at discord as always, felipe23. What I really need is to make the cellphone reads the site without sending the right bars to the bottom. Anything that is needed just tell me, the live version is up at the same url shown in the image. Regards! :)


Imagen_de_WhatsApp_2024-05-04_a_las_01.01.56_ac6a06c0.jpg
 
Back
Top Bottom