How do we transfer data from the controller for viewing to zend?

I start with the zend 1.11 framework. As we pass the different value of $ data in the view from the controller to view, as in codeigniter, we go through this.

$data['pass_one_thing'] = $this->model1->pass_all_mangoes();
$data['pass_another_thing'] = $this->model2->pass_all_oranges();
$this->load->view('viewfile', $data);

then in the views we get the values โ€‹โ€‹$ pass_one_thing and $ pass_another_thing with foreach loops in the same view file.

How to switch from different model functions in one view?

How do we get such a thing in zend? I am new to zend and a little confused.

+5
source share
2 answers

This can be done something like this:

$this->view->data = $data;

Or use the function assign:

$this->view->assign('data', $data);

edit: How to switch from another model function in one view Not quite sure, but taking your example:

$this->view->data['pass_one_thing'] = $this->model1->pass_all_mangoes();
$this->view->data['pass_another_thing'] = $this->model2->pass_all_oranges();
$this->load->view('viewfile', $data);

Then, in your opinion, you will get access to this trough:

$this->data['pass_one_thing']
$this->data['pass_another_thing']
+7

:

$this->view->myVar = "something";

:

echo $this->myVar;

, .

+10

All Articles