Sti*_*MAN 1 symfony1 stylesheet symfony-1.4
有没有人知道如何使用Symfony 1.4在模板中添加样式表?
我已经尝试了我能想到的一切,从修改frontend/config/view.yml到修改模板本身 - 两个都可以.
我从搜索中看到,其他人也有同样的问题.在使用include_stylesheets和use_stylesheets之间似乎存在冲突 - 但是在AFAIK的任何地方都没有记录.
编辑:
好的,我想我现在明白了.您应该添加include_stylesheets()到布局文件的head部分:
<html>
<head>
<title>This is the title</title>
<?php include_stylesheets() ?>
</head>
<body>
<!-- ... -->
Run Code Online (Sandbox Code Playgroud)
然后在模板文件中,您将使用use_stylesheet()为此模板添加特定样式表:
<?php use_stylesheet('/path/to/stylesheet.css') ?>
Run Code Online (Sandbox Code Playgroud)
从API文档:
include_stylesheets()<link>为view.yml中配置的所有样式表 打印标签或添加到响应对象.
use_stylesheet()
将样式表添加到响应对象.
对于Javascript也是如此.
根据API文档,它仍然应该在1.4中工作,sfWebResponse仍然有这个方法:
Run Code Online (Sandbox Code Playgroud)addStylesheet ($file, $position, $options) $file The stylesheet file $position Position $options Stylesheet options Adds a stylesheet to the current web response.
至少存在该方法.
究竟是什么问题?如果要调用该方法或未添加样式表,是否会出现错误?
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |