php - ZF2 headLink 辅助订购

标签 php model-view-controller zend-framework2 view-helpers

我在布局上使用 $this->headLink()->appendStylesheet() 设置了少量样式,并且我正在尝试从 View 内部附加另一个样式表。但是, View 中的样式表始终是 headLink 堆栈中渲染的第一个样式表。

布局.phtml:

echo $this->headLink()->appendStylesheet($this->basePath('css/styleA.css'))
                      ->appendStylesheet($this->basePath('css/styleB.css'));

然后在 View 中我尝试了以下操作

查看.phtml:

$this->headLink()->appendStylesheet($this->basePath('css/sub/styleC.css'));

$this->headLink()->offsetSetStylesheet(100, $this->basePath('css/sub/styleC.css'));

但是,两者最终都以 styleC 为呈现的第一个链接标记。我知道 subview 首先渲染(即,view.phtml 在layout.phtml 之前渲染),但我认为只要渲染器相同,像 headLink 和 headScript 这样的助手就有一个共享堆栈。这个假设错了吗?

最佳答案

您需要在布局中添加样式表,例如:

echo $this->headLink()->prependStylesheet($this->basePath('css/styleB.css'))
                      ->prependStylesheet($this->basePath('css/styleA.css'));

并像之前一样在 View 中附加样式表。

关于php - ZF2 headLink 辅助订购,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17790536/

相关文章:

objective-c - Controller 是否应该知道iOS应用程序中的NSManagedObjectContext

c# - 如何将 Json 字符串转换为 C# Class 对象?

php - for循环中的动态变量名

php - 替换 heredoc 语法

php - 如何构建电子商务应用程序的数据库?

javascript - 使用 yui 在纯菜单中寻找正确的 jQuery 选择器

c# - 部分 View 提交

javascript - Zend Framework 2 中根据请求类型在同一路由上触发不同的操作

php - 采埃孚 2 :Catchable fatal error: Argument 1 passed to Zend\View\HelperPluginManager

php - 如何使用 zend2 和 dompdf 创建 pdf