summaryrefslogtreecommitdiffstats
path: root/user_guide
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-03-08 22:43:54 +0100
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-03-08 22:43:54 +0100
commit60ed1a305bea9f879489a1b4c7ac223b6cf3e132 (patch)
tree7708e485032622937ec53f1853e4ef831aa8be57 /user_guide
parent9869f890f21c30d0016cd28d8ea1bdb89da3e96a (diff)
Added $this->output->set_content_type() and method chaining to other methods.
Diffstat (limited to 'user_guide')
-rw-r--r--user_guide/changelog.html2
-rw-r--r--user_guide/libraries/output.html15
2 files changed, 17 insertions, 0 deletions
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index d759686e9..815590dc1 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -74,6 +74,8 @@ Hg Tag: n/a</p>
<li class="reactor">Added <kbd>decimal</kbd>, <kbd>less_than</kbd> and <kbd>greater_than</kbd> rules to the <a href="libraries/form_validation.html">Form validation Class</a>.</li>
<li class="reactor"><a href="libraries/input.html">Input Class</a> methods <kbd>post()</kbd> and <kbd>get()</kbd> will now return a full array if the first argument is not provided.</li>
<li class="reactor">Secure cookies can now be made with the <kbd>set_cookie()</kbd> helper and <a href="libraries/input.html">Input Class</a> method.</li>
+ <li class="reactor">Added <kbd>set_content_type()</kbd> to <a href="libraries/output.html">Output Class</a> to set the output <kbd>Content-Type</kbd> HTTP header based on a MIME Type or a config/mimes.php array key.</li>
+ <li class="reactor"><a href="libraries/output.html">Output Class</a> will now support method chaining.</li>
</ul>
</li>
</ul>
diff --git a/user_guide/libraries/output.html b/user_guide/libraries/output.html
index ab8f1d683..25ec521b1 100644
--- a/user_guide/libraries/output.html
+++ b/user_guide/libraries/output.html
@@ -78,6 +78,21 @@ It is possible, however, for you to manually intervene with the output if you ne
For example, if you build a page in one of your controller functions, don't set the output until the end.</p>
+<h2>$this->output->set_content_type();</h2>
+
+<p>Permits you to set the mime-type of your page so you can serve JSON data, JPEG's, XML, etc easily.</p>
+
+<code>$this->output<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_content_type('application/json')<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_output(json_encode(array('foo' => 'bar')));<br/>
+<br/>
+$this->output<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php<br/>
+&nbsp;&nbsp;&nbsp;&nbsp;->set_output(file_get_contents('files/something.jpg'));</code>
+
+<p><strong>Important:</strong> Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect.</p>
+
+
<h2>$this->output->get_output();</h2>
<p>Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:</p>