Closed (fixed)
Project:
Front Page
Version:
5.x-1.8
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
9 May 2007 at 23:51 UTC
Updated:
30 Jan 2010 at 17:35 UTC
I am attempting to create a mobile version of my site, I have the mobi_loader module installed that uses the mobi theme. However, I don't see a way to designate another specific node as the main landing page for the users coming in on the .mobi domain. Right now I have a Panel as my main page, but I want to specifiy i.e. ...site.com/mobile-home as the front page for users coming in on the .mobi domain.
A little info about my site:
Drupal 5.1
Single database
Thanks in advance... Is this something that is possible with this module, or should I hack around the template files to redirect based on url inside the mobi theme? thanks!
Comments
Comment #1
Dublin Drupaller commentedHi thegenericgeek,
I haven't tried this, but, you could plop the following in your front_page settings. I've included comments so you can follow what's going on.
OPTION #1
------------
redirect users based on the domain name.
OPTION #2
----------
Redirect users based on browser type. In other words, it checks for the browser agent and does a cross check against a list of mobile browser types.
As I say, I haven't tested the above...I think I would probably opt for OPTION 2 which detects whether the user is browsing using a mobile phone.
Can you report back up here if that works for you or if you run into problems (the second snippet might need to be tweaked for PHP 5)?
I think the front_page.module probably should have a mobile phone detect option soon...more and more websites are being designed now for mobile browsing and sometimes, like in your case, it's not enough to simple theme everything for mobile browsers....a seperate front page is required.
Dub
Comment #2
Dublin Drupaller commentedsorry..there's a typo in my comments for the section snippet..it should read
Dub
Comment #3
thegenericgeek commentedThanks for the quick response, I will try option two when I get home from work and report back. Thanks again!
Comment #4
thegenericgeek commentedInstalled the new modified code, working like a champ. Page is not so pretty on your phone, but at least it's redirecting to where I need it to go for now! Thanks for all your help!
Check out on your phone at Genericgeek.mobi, to see the site the way it's supposed to look, it's Genericgeek.com.
Any chance that this bit of code will make it into the module options in the future???
Comment #5
abqaria commentedi tried to do it but failed
i copied the following code
$newfront = 'mobile_blogging'; // specify where you want people coming from $checkdomain
$regularfront = 'front'; // specify where you want people coming not from $checkdomain
$checkdomain = www.ibloggers.mobi; // the domain name you want to redirect visitors coming from
$comingfrom = $_SERVER["HTTP_REFERER"]; // checks to see where the visitor is coming from
if (stristr($comingfrom, $checkdomain))
{
// redirect users coming from $checkdomain to $newfront
drupal_goto($path = $newfront, $query = NULL, $fragment = NULL);
}
else {
// redirect regular users to $regularfront
drupal_goto($path = $regularfront, $query = NULL, $fragment = NULL);
}
$mobile_browser = '0';
if(preg_match('/ (up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|vodafone|o2|pocket|mobile|pda|psp)/i',strtolower($_SERVER['HTTP_USER_AGENT']))){
$mobile_browser++;
}
if(((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'text/vnd.wap.wml')>0) or (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0)) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))){
$mobile_browser++;
}
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4));
$mobile_agents = array('acs-','alav','alca','amoi','audi','aste','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno','ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-','maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','oper','opwv','palm','pana','pant','pdxg','phil','play','pluc','port','prox','qtek','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda','xda-');
if(in_array($mobile_ua,$mobile_agents)){
$mobile_browser++;
}
if($mobile_browser>0){
// redirect users browsing using a mobile phone to $newfront
drupal_goto($path = $newfront, $query = NULL, $fragment = NULL);
}
else {
// redirect users not using a mobile phone to $regularfront
drupal_goto($path = $regularfront, $query = NULL, $fragment = NULL);
}
and did paste it in the front_page module after the settings area
can anyone help
Comment #6
Dublin Drupaller commentedOpen this back up if you're still stuck.