Zend Framework:是否有视图助手在布局类中显示视图名称?

发布于 2024-12-11 22:46:20 字数 581 浏览 0 评论 0原文

正如标题所示,我试图找到一种显示当前作为布局一部分显示的视图标题的方法。我正在尝试执行此操作,以便在选择不同视图时动态填充页面标题。

在伪代码中:

<div>
   <div id="header"><h1>My website</h1></div>
   <div id="main">
           <?php echo "<h2>" . SOME WAY OF ECHOING THE VIEW NAME HERE . "</h2>"; ?>
           <?php echo $this->layout()->content; ?>
   </div>
   <div id="footer"><p>2011 My website.com></p>
</div>

我已经浏览了 Zend 文档,我能找到的最接近的东西是标题链接。但是,我无法从此帮助程序获取值并将其插入变量中,以便我可以将其文本显示为视图的页面标题。

谢谢。

As the title suggests, I'm trying to find a way of displaying the title of the View currently being displayed as part of the layout. I'm trying to do this so that the page title is dynamicly populated when a different view is selected.

In psuedocode:

<div>
   <div id="header"><h1>My website</h1></div>
   <div id="main">
           <?php echo "<h2>" . SOME WAY OF ECHOING THE VIEW NAME HERE . "</h2>"; ?>
           <?php echo $this->layout()->content; ?>
   </div>
   <div id="footer"><p>2011 My website.com></p>
</div>

I've been through the Zend documentation and the closest thing I could find was the headlink. However, I was unable to get the value from this helper and shoehorn it into a variable so that I could display its text as a page header for the view.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梅倚清风 2024-12-18 22:46:20

您可以将操作名称(或根据需要与模块组合)传递到控制器内的布局。

$layout = $this->_helper->layout->getLayoutInstance();
$layout->viewName = $this->_getParam("action");

有点脏,但可以用

You could pass the action name (or combine with the module if needed) to the layout within the controller.

$layout = $this->_helper->layout->getLayoutInstance();
$layout->viewName = $this->_getParam("action");

Kind of dirty, but it would work

无妨# 2024-12-18 22:46:20

我不太确定我是否理解正确,但是有一个叫做 ZendFramework 中的占位符。基本上,您定义占位符,然后用您想要的任何内容填充它。

I´m not quite sure if I understood you right, but there´s something called a placeholder in ZendFramework. Basically you define the placeholder and fill it afterwards with whatever you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文