• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display raw content instead of html

Hello !

I am developing a CI app, and I have a controller with a function that is used to view a post :

function view($id=0)

            $check['idUser'] = $this->tank_auth->get_user_id();
            $check['post'] = $this->MPost->getAllPosts_by('id',$id);
            $data['title'] = "...";
            $data['subtitle'] = " ... ..";
            $data['elementidcontainer'] = "..";
            $data['elementid'] = "...";
            $data['currentuser'] = $this->tank_auth->get_user_id();
            $data['poster'] = $this->MPost->getPoster($id);
            $data['posterpostnum'] = $this->MUsers->count_byuser('post',$data['poster'][0]['idUser']);
            $data['posterconnections'] = $this->MUsers->myConnections($data['poster'][0]['idUser']);



The function is simplified here.

It is working great but I want to change it. Actually I would like to change the last section to load view, header and footer, in a way I can send the array $data in the browser as a raw text.

I read a lot about session flashdata, but I don't know if I have to send the array to another controller function or could I write a simple view that will contain the data and display it as a raw.

Bu raw I mean something similar to what github has when you read a code (they have a raw button that render a text from a textarea

Can anyone guide me through this ?

Thanks in advance

Use the HTML <code> tag to display code. You can also use a syntax highlighter such as Geshi to stylize/colorize it.

Thank you CroNiX

But this is not what I want to do actually. I want to view the post as text and not rendered in any format, just raw text

Then run it through htmlentities() so it converts the opening code tags so the browser will display them instead of execute them and then display it between <code> tags in the html.

$your_code = '&lt;?php echo "hello"; ?&gt;';
<code>&lt;?php echo htmlentities($your_code); ?&gt;</code>

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.