Results 1 to 2 of 2
  1. #1
    WTF Groupie Array
    Join Date
    Oct 2006
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I change the content type of a view?

    How do I change the content type of a view? I have one that is json-formatted and needs to be read by a flash app and so I want the content type to at least be text/plain, not text/html

  2. #2
    Junior Member Array
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts


    You will want to create a new layout file in your application, and name it text.ctp (/app/views/layouts/text.ctp).

    In this file (text.ctp), add the following code:

    Code:
    <?php 
        header("Content-type: text/plain"); 
        echo $content_for_layout; 
    ?>
    Then in your controller action, which will be using this text layout, add the following to the top of that method:

    Code:
    $this->layout = 'text';
    And you should be set.

    Hope this helps!


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •