Welcome Guest, Not a member yet? Register   Sign In
Fetch request from google mobile robot does not set is_mobile() to TRUE
#1

[eluser]tomyt[/eluser]
I'm using this tool test how Google indexes the mobile version of my site.

However, regardless of which mobile version I choose (Mobile: cHTML, XHTML/WML, or Smartphone) it always returns the desktop version of the site.

I know settings can be tweaked in the user-agents config file, but I'm looking for guidance as to how. This is important because it's against google's policies to server a different version of the page to google than your regular users. And if they are both using a cellphone, this is something I'm currently doing.

Is there a string I can add to the user agent arrays to detect google mobile bot? And more importantly, where should I include it? Since the order of the array also matters.

Thanks a ton for your help.
#2

[eluser]tomyt[/eluser]
Incase anyone else ever faces this problem, I'll post the solution I've been meaning to post for a while.

in system/libraries/User_agent.php

Code:
private function _set_robot()
{
  if (is_array($this->robots) AND count($this->robots) > 0)
  {
   foreach ($this->robots as $key => $val)
   {
    if (preg_match("|".preg_quote($key)."|i", $this->agent))
    {
     $this->is_robot = TRUE;
     $this->robot = $val;
     //**ADD THE FOLLOWING LINE HERE**
     $this->_set_mobile();
     return TRUE;
    }
   }
  }
  return FALSE;
}

This will set the mobile correctly even when a robot is visiting.
#3

[eluser]Aken[/eluser]
I added this as a pull request. Nice addition, thanks.




Theme © iAndrew 2016 - Forum software by © MyBB