我的布局和viewModel出现问题 我的设计要求在我的viewModel中设置标题,例如“博客类别”,将其推送到布局。
我正在使用$ this-> headTitle()来设置页面的标题,但我无法在其他任何地方获取它。 由于每页布局有很多变化,我不得不在布局中使用partial。
single.phtml
<?php echo $this->partial('lendstudy/partial/basic/top'); ?>
<div class="container_12 clearfix">
<div id="content_wrapper">
<?= $this->partial('lendstudy/partial/basic/title'); ?>
<?php echo $this->content; ?>
<?= $this->partial('lendstudy/partial/sidebar/left'); ?>
</div>
</div>
<?php echo $this->partial('lendstudy/partial/basic/bottom');
我在视图中设置标题标题 index.phtml来自博客模块中的类别
<?php
$title = $this->translate('Categories');
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<p><a href="<?php echo $this->url('kryuu-blog/category', array('action'=>'add'));?>">Add new category</a></p>
<table class="table table-bordered table-hover">
<tr>
<th>Category</th>
<th> </th>
<th> </th>
</tr>
<?php foreach($categories as $category) : ?>
<tr>
<td><?php echo $this->escapeHtml($category->getName());?></td>
<td>
<a href="<?php echo $this->url('kryuu-blog/category', array('action' => 'edit', 'id' => $category->getId())); ?>">[Edit]</a>
</td>
<td>
<a href="<?php echo $this->url('kryuu-blog/category', array('action' => 'delete', 'id' => $category->getId())); ?>" onclick="return confirm('Are you sure?')">[Delete]</a>
</td>
</tr>
<?php endforeach; ?>
</table>
然后需要在partial / basic / title中输出。
title.phtml
<div class="grid_12 page_title">
<h1><?= $this->headTitle(); ?><span class="subtitle"><?= $this->translate('More information about the Lend Study association') ?></span></h1>
<div class="page_navigation">
<?php $partial = array('lendstudy/partial/basic/breadcrumbs', 'default') ?>
<?php $this->navigation('navigation')->breadcrumbs()->setPartial($partial) ?>
<?php echo $this->navigation('navigation')->breadcrumbs()->render() ?>
</div>
</div>
我该怎么做?