📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Zend Framework / Laminas Views in Laminas

Views in Laminas

5 min read
Use view helpers (url, escapeHtml, paginationControl) and render partials in Laminas views.

Views and Layouts

<!-- module/Blog/view/layout/layout.phtml -->
<!DOCTYPE html>
<html>
<head>
    <title><?= $this->headTitle()->setSeparator(" - ")->setAutoEscape(false) ?></title>
    <?= $this->headLink()->prependStylesheet($this->basePath("css/app.css")) ?>
</head>
<body>
    <?= $this->content ?>
    <?= $this->inlineScript() ?>
</body>
</html>

<!-- module/Blog/view/blog/post/index.phtml -->
<?php $this->headTitle("Blog Posts"); ?>
<h1>Blog Posts</h1>

<?php foreach ($this->posts as $post): ?>
    <h2><?= $this->escapeHtml($post->title) ?></h2>
    <p><?= $this->escapeHtml($post->body) ?></p>
    <a href="<?= $this->url("blog/post", ["action"=>"view","id"=>$post->id]) ?>">Read More</a>
<?php endforeach ?>

<!-- View helpers -->
<?= $this->partial("blog/post/row", ["post" => $post]) ?>
<?= $this->paginationControl($paginator, "Sliding", "pagination") ?>