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

#1
[eluser]Radou[/eluser]
Hello !

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

Code:
function view($id=0)
        {
    

            $check['idUser'] = $this->tank_auth->get_user_id();
            $check['post'] = $this->MPost->getAllPosts_by('id',$id);
            
            if(sizeof($check['post'])==0)
            {
            
            $this->load404page();
          
            }else{
    
          
            $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']);
    

          

   $this->load->vars($data);
          $this->load->view('header');
          $this->load->view('view-post');
          $this->load->view('footer');
        }
        }


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


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

#3
[eluser]Radou[/eluser]
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

#4
[eluser]CroNiX[/eluser]
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.

Code:
&lt;?php
$your_code = '&lt;?php echo "hello"; ?&gt;';
?&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.