lautr.com

Hannes Blog for Development and Stuff besides

sub-view in zend framework, use a view in a view

| Keine Kommentare

How to include one view in to another view in zend framework:

IndexController.php :

public function articleAction(){
	$this->view->content = $this->_model->getContent();
    $this->view->comments = new Zend_view;
	$this->view->comments->addBasePath('/full/path/to/views');
	$this->view->comments->comments = $this->_model->getComments();

	$output = $this->view->render('index.phtml');

	print $output;
}

index.phtml :

<?= $this->comments->render('comments.phtml'); ?>

comments.phtml :

<?php foreach($this->comments as $comment){ ?>
    <span><?= $comment->title ?></span>
    <p><?= $comment->text ?></p>
<?php } ?>

Autor: Hannes

Hi! I’m Johannes Lauter a 26 year old Web Application Developer based in Berlin ... more

Hinterlasse eine Antwort

Pflichtfelder sind mit * markiert.

*