I have all sort of problems with this part of the code (I'm using drupal-6.12 maybe this is the reason..):
function mobile_tools_create_mobile_url($url) {
$url_parsed = parse_url($url);
$url = $url_parsed['host'];
$url = explode('.', $url);
if (count($url) == 3 ) {
$url[0] = 'm';
return 'http://'. implode('.', $url);// . $url_parsed['path'];
// $significant = (strlen($mobile_url['path']) > strlen($desktop_url['path'])) ? 'mobile' : 'desktop'; //we check the most significatn url (with the longest path)
// if (preg_match("|" . $desktop_url['path'] . "|", request_uri())) {
// if (preg_match("|" . $mobile_url['path'] . "|", request_uri())) {
// return $significant; // if both patterns match, return the significant
// }
return 'desktop';
// }
// else {
// return 'mobile';
// }
The problem came out because path is not a valid index.
print_r($url_parsed) -> Array ( [scheme] => http [host] => www.domainname.it )
Comments
Comment #1
twom commentedI fixed the problem by checking the existence of the path element (and in most cases, the path part is actually empty)
Comment #2
twom commented