From 60ed1a305bea9f879489a1b4c7ac223b6cf3e132 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 8 Mar 2011 21:43:54 +0000 Subject: Added $this->output->set_content_type() and method chaining to other methods. --- user_guide/changelog.html | 2 ++ user_guide/libraries/output.html | 15 +++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'user_guide') 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

  • Added decimal, less_than and greater_than rules to the Form validation Class.
  • Input Class methods post() and get() will now return a full array if the first argument is not provided.
  • Secure cookies can now be made with the set_cookie() helper and Input Class method.
  • +
  • Added set_content_type() to Output Class to set the output Content-Type HTTP header based on a MIME Type or a config/mimes.php array key.
  • +
  • Output Class will now support method chaining.
  • 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.

    +

    $this->output->set_content_type();

    + +

    Permits you to set the mime-type of your page so you can serve JSON data, JPEG's, XML, etc easily.

    + +$this->output
    +    ->set_content_type('application/json')
    +    ->set_output(json_encode(array('foo' => 'bar')));
    +
    +$this->output
    +    ->set_content_type('jpeg') // You could also use ".jpeg" which will have the full stop removed before looking in config/mimes.php
    +    ->set_output(file_get_contents('files/something.jpg'));
    + +

    Important: Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect.

    + +

    $this->output->get_output();

    Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:

    -- cgit v1.2.3-24-g4f1b