4

I'm creating a wrapper class in the Zend framework to encapsulate some data output and the pagination control.

How do I output this line from the view in the controller:

<?= $this->paginationControl($this->oPaginator, 'Sliding', 'pagination-control.phtml')?>

Thanks in advance.

...Answered my own question:

$this->view->oPaginator = $this->oPaginator;
echo $this->view->paginationControl($this->view->oPaginator, 'Sliding', 'pagination-control.phtml');
j0k
  • 22,600
  • 28
  • 79
  • 90
Rupert
  • 1,629
  • 11
  • 23
  • This doesn't really make sense. Where is that line now and why does it need to outside of the the View? – Jake N Nov 21 '11 at 11:07

1 Answers1

2

You can access the view object in the controller with $this->view. So you should be able to echo it like this:

echo $this->view->paginationControl($this->view->oPaginator, 'Sliding', 'pagination-control.phtml');

But I think there something wrong with your application if you need to echo this in the controller. Why do you want to do this?

Jona
  • 2,087
  • 15
  • 24
  • Thanks for this. It's an ajax call and I've been asked to output the data from the controller rather than from the view. – Rupert Nov 21 '11 at 11:12
  • Then render the view into the response. `$this->_helper->json(array('body' => $this->view->render('some_ctrl/some_view.phtml')))`. – nevvermind Nov 22 '11 at 06:15