summaryrefslogtreecommitdiffstats
path: root/user_guide/libraries/user_agent.html
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-01-06 18:40:10 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-01-06 18:40:10 +0100
commitdac1b468d5432ff9166fe221ac520b5050a65f0e (patch)
tree6e3d80bf9d37347ede0244b480f08f8a330a1957 /user_guide/libraries/user_agent.html
parentc2e9225eec976326df36b666d6baf6db29eee831 (diff)
Altered User agent library so that is_browser(), is_mobile() and is_robot() can optionally check for a specific browser or mobile device.
Diffstat (limited to 'user_guide/libraries/user_agent.html')
-rw-r--r--user_guide/libraries/user_agent.html25
1 files changed, 25 insertions, 0 deletions
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.)
<h2>$this->agent->is_browser()</h2>
<p>Returns TRUE/FALSE (boolean) if the user agent is a known web browser.</p>
+<code> if ($this->agent->is_browser('Safari'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You are using Safari.';<br />
+}<br />
+else if ($this->agent->is_browser())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;echo 'You are using a browser.';<br />
+}</code>
+
+<p class="important"><strong>Note:</strong>&nbsp; The string "Safari" in this example is an array key in the list of browser definitions.
+You can find this list in <dfn>application/config/user_agents.php</dfn> if you want to add new browsers or change the stings.</p>
+
<h2>$this->agent->is_mobile()</h2>
<p>Returns TRUE/FALSE (boolean) if the user agent is a known mobile device.</p>
+<code> if ($this->agent->is_mobile('iphone'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('iphone/home');<br />
+}<br />
+else if ($this->agent->is_mobile())<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('mobile/home');<br />
+}<br/>
+else<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$this->load->view('web/home');<br />
+}</code>
+
<h2>$this->agent->is_robot()</h2>
<p>Returns TRUE/FALSE (boolean) if the user agent is a known robot.</p>