• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] : controller functions calling from within fragment views, PHP4 -> PHP5

#3
[eluser]tomcode[/eluser]
Sorry, did show my code example too simplictic. I'm passing information to the controller.
Each view file contains different parameters, so I cannot set the values in the controller.

The main idea is to keep the data out of the controller.
Code:
function insert_code($file = FALSE)
{
  if ($file)
  {
    $open = "<?php ";
    $file .= '.code.php';
    $code = $open .file_get_contents(APPPATH.'views/code/'.$file);
    $coloredstring =highlight_string($code,TRUE);
    $results[] = '<div class="code">';
    $results[] = str_replace('&lt;?php ','',$coloredstring);
    $results[] ='</div>';
    return implode("\r\n", $results);
  }
}

And in the fragment views i have
file 1
Code:
&lt;?=$this->insert_code('some_file_name');?&gt;
file 2
Code:
&lt;?=$this->insert_code('some_other_file_name');?&gt;

I also call the function several times per fragment view.


Messages In This Thread
[solved] : controller functions calling from within fragment views, PHP4 -> PHP5 - by El Forum - 10-02-2007, 07:30 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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