• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please give me example of returning views as data

#1
[eluser]Mario "St.Peter" Valentino[/eluser]
dear,

can anybody here give example about returning views as data.
i hope the full code( from controllers and view).
i'm newbie to codeigniter.
Please do me a favor


Thanks

#2
[eluser]Glazz[/eluser]
http://ellislab.com/codeigniter/user-gui...views.html

To return a view to a string you can use:
Code:
class Welcome extends CI_Controller
{
    function index()
    {
        $data_to_send['title'] = 'Your webpage title';
        $string = $this->load->view('your_file.php', $data_to_send, true);
    }
}

Is this what you need ?

#3
[eluser]Mario "St.Peter" Valentino[/eluser]
i still confuse. here you save views to variable $string. how i display the result ?

#4
[eluser]Glazz[/eluser]
with:
Code:
echo $string;

but if you don't want to save the result to a string just use
Code:
$this->load->view('your_file.php', $data_to_send);

and it will show you the view automatically

#5
[eluser]Mario "St.Peter" Valentino[/eluser]
ok now i understand. Thanks my friend for your explanation


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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