Php 如何从Zend Framework 1中的模块加载css和javascript文件?
我有休闲结构Php 如何从Zend Framework 1中的模块加载css和javascript文件?,php,zend-framework,module,path,assets,Php,Zend Framework,Module,Path,Assets,我有休闲结构 /app application/ configs/ modules/ default/ controllers/ layouts/ views/ forms/ profile/ controllers/
/app
application/
configs/
modules/
default/
controllers/
layouts/
views/
forms/
profile/
controllers/
layouts/
views/
forms/
assets/
css/
js/
images/
library/
public/
css/
js/
images/
uploads/
如何从中加载js和css文件
/application/modules/profile/assets/…
并使用类似于
$this->view->headLink()->appendStylesheet('path/to/file')代码>
对这个问题有什么想法吗?只管理对CSS文件的引用,这些文件在HTML页面的部分中呈现。这些样式表应该始终具有公共URL,这意味着它们必须位于“public”文件夹中的某个位置
一种解决方案是将CSS文件移到那里。另一个解决方案是使用某种PHP脚本,从“public”文件夹外的位置读取CSS文件,然后打印内容。Zend Framework没有标准组件,因此我建议重新组织项目,以便所有CSS都可以驻留在“public”文件夹中,我同意P44T的观点,即样式表应始终保存在公用文件夹中。在某些情况下,您可能需要像这样从模块中添加一些其他样式。这样做的一个例子是,如果您希望将模块与应用程序分开分发,并且不希望将样式表与添加模块分开添加
以下是一个示例,说明了如何从任何角度实现这一点:
<?php $this->headStyle()->captureStart() ?>
// add plain css or include a file like this:
<?php include APPLICATION_PATH . 'modules/[modulename]/assets/css/style.css'; ?>
<?php $this->headStyle()->captureEnd() ?>
//添加普通css或包含如下文件:
希望这有帮助:)