Zend Framework - 如何在视图内调用 CSS?
我想在特定视图的标题上注入 css。 我查看了 Zend 手册,它讨论了某种帮助类来执行此操作。但是,我不确定我们是否有所有可用的帮助者。
我们有那个随时可用的助手类吗?
这样做的例子是什么?
I would like to inject a css on a header, on a specific view.
I've looked into Zend manual and it talks about some sort of helper class for doing so. However, I'm not sure if we have all helpers available to us.
Do we have that helper class always available?
What would be an example of doing such a thing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它是核心助手之一,因此除非您有非常奇特的设置,否则您肯定可以使用它。从手册中,通常您需要执行以下操作:
在视图文件中初始化您的样式。在布局文件中,您需要使用以下命令回显所附加的内容:
请注意,初始化和最终回显都是必需的。
编辑:这假设您正在内联执行此操作 - 如果您想注入链接的 CSS 文件,那么您将使用 headlink 帮助器;这是同样的事情,您初始化它,然后在您的布局中回显它。
It's one of the core helpers, so you'll definitely have it available unless you've got a very exotic setup. From the manual, typically you'll want to do something like:
in your view file to initialise your style. In your layout file you'll need to then echo out what you've appended using:
Note that both the initialising and that final echo are required.
Edit: this assumes you're doing it inline - if you want to inject a linked CSS file then you'll use the headlink helper; that's the same deal, you initialise it and then echo it out in your layout.