Welcome Guest, Not a member yet? Register   Sign In
send data + load->view();
#1

[eluser]WebbHelp[/eluser]
Hi!

I am a CodeIgniter beginner and got some question about send data to the page I load.
1. I think when I write:

$this->general['title'] = 'Welcome to my Blog';
$this->load->view('blog_view',$this->general);

The view funktion "convert" my array that I send with the function and create variables of it so I can get the variables by:
echo $title;

Is that right?

2. And, if I use $this-> is that; make variable public in the whole class?

3. You know when I write base_url(); I get the "base url".
Where do I get that class from?
I mean, I don't need to write for example: $this->helper->url('base_url'); to get it //If I have loaded my url helper class before.

Where do I get that class from?

Thanks //WebbHelp
#2

[eluser]ElShotte[/eluser]
$data = array(
'title' => 'Website',
'style' => array('style_css' => 'style_001.css',),
'page' => 'help',
);

$this->load->view('layouts/layout_top', $data);

//Inside the actual view file, to display your title amongst your HTML code just <?=$title?>. Each Key name in the array is your variable name.

//To display or get your URL you can use one of the following.

echo base_url();

//If you want to make a link to let's say your "Help" controller, use the following

site_url("help")

//base_url() is self explanatory, meanwhile, you pass a value to site_url and it generates link for you.
#3

[eluser]WebbHelp[/eluser]
But when I use site_url(); on a form action I come to index.php/index.php/blog
when I use base_url(); I come to index.php/blog

And my question on base_url was, wich class is that, do I get the class with base_url(); automatically?
#4

[eluser]ElShotte[/eluser]
Use the form helper, it has the form_open() function. Read more in the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB