summaryrefslogtreecommitdiffstats
path: root/user_guide
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
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')
-rw-r--r--user_guide/changelog.html1
-rw-r--r--user_guide/libraries/user_agent.html25
2 files changed, 26 insertions, 0 deletions
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 09efc5434..a6332d64d 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -113,6 +113,7 @@ Hg Tag: </p>
<li>Altered Form_Validation library to allow for method chaining on <kbd>set_rules()</kbd>, <kbd>set_message()</kbd> and <kbd>set_error_delimiters()</kbd> functions.</li>
<li>Altered Email Library to allow for method chaining.</li>
<li>Added <kbd>request_headers()</kbd>, <kbd>get_request_header()</kbd> and <kbd>is_ajax_request()</kbd> to the input class.</li>
+ <li>Altered <a href="libraries/user_agent.html">User agent library</a> so that <kbd>is_browser()</kbd>, <kbd>is_mobile()</kbd> and <kbd>is_robot()</kbd> can optionally check for a specific browser or mobile device.</li>
</ul>
</li>
<li>Database
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>