【发布时间】:2011-09-04 00:11:34
【问题描述】:
Css 路径无法正常工作。有人可以帮我解决这个问题。我是 Zend 的新手。
main.css 位于 public/css 文件夹的根目录下。跟着这个链接学习http://framework.zend.com/manual/en/zend.application.quick-start.html
问题:
我正在定义 headLink()->appendStylesheet('/css/main.css') ?> 在布局中见下文。但这没有生成正确的路径,因此没有应用样式。我想用 headlink() 函数生成链接。 main.css 应该从根目录的 public/css 文件夹中渲染
缩小问题。如果我在 css like 之前删除 /,这 正在工作。 为什么会这样?
<?= $this->headLink()->appendStylesheet('css/main.css') ?>
文件夹结构
下面是index.php
<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_PATH', BASE_PATH . '/application');
// Include path
set_include_path(
BASE_PATH . '/library'
);
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
: 'production'));
// Zend_Application
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$application->run();
【问题讨论】:
-
请定义究竟什么是“不能正常工作”。
-
@deceze ,编辑了我的问题并添加了问题。见问题顶部。我想使用 headLink() 函数而不是 .
-
查看页面源代码时输出的是什么?
-
@tim-fountain ,编辑了我的问题。请阅读
-
您仍然没有提供足够的信息让我们回答您的问题。当您说它“无法正常工作”时,您的意思是
<link>元素没有被输出吗?如果是,它是否以与您提供的路径不同的路径输出?如果您直接在浏览器中查看样式表是否有效 - localhost/css/main.css ?
标签: php zend-framework