From dac1b468d5432ff9166fe221ac520b5050a65f0e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 6 Jan 2011 17:40:10 +0000 Subject: Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device. --- user_guide/libraries/user_agent.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'user_guide/libraries/user_agent.html') diff --git a/user_guide/libraries/user_agent.html b/user_guide/libraries/user_agent.html index 944f1ed86..d2f79d2ec 100644 --- a/user_guide/libraries/user_agent.html +++ b/user_guide/libraries/user_agent.html @@ -111,9 +111,34 @@ echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)

$this->agent->is_browser()

Returns TRUE/FALSE (boolean) if the user agent is a known web browser.

+ if ($this->agent->is_browser('Safari'))
+{
+    echo 'You are using Safari.';
+}
+else if ($this->agent->is_browser())
+{
+    echo 'You are using a browser.';
+}
+ +

Note:  The string "Safari" in this example is an array key in the list of browser definitions. +You can find this list in application/config/user_agents.php if you want to add new browsers or change the stings.

+

$this->agent->is_mobile()

Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.

+ if ($this->agent->is_mobile('iphone'))
+{
+    $this->load->view('iphone/home');
+}
+else if ($this->agent->is_mobile())
+{
+    $this->load->view('mobile/home');
+}
+else
+{
+    $this->load->view('web/home');
+}
+

$this->agent->is_robot()

Returns TRUE/FALSE (boolean) if the user agent is a known robot.

-- cgit v1.2.3-24-g4f1b