我尝试基于主题创建CakePHP应用程序。我使用的是CakePHP 2.0.0的最新版本
我的申请包含该文件
/app/Controller/AppController.php
class AppController extends Controller
{
public $helpers = array('Html', 'Session', 'Form');
public function beforeFilter()
{
$this->setupTheme();
}
private function setupTheme()
{
$this->viewClass = 'Theme';
$this->theme = 'Mars';
$this->layout = 'admin';
}
}
/app/Controller/LanguagesController.php
class LanguagesController extends AppController
{
public $name = "Languages";
public function index()
{}
}
/app/View/Themed/Mars/Languages/index.php
// Currently Empty
/app/View/Themed/Mars/Layouts/admin.ctp
<?php echo $this->Html->docType('xhtml-strict'); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<?php echo $this->Html->charset(); ?>
<meta name="author" content="Nikos Merianos" />
<title><?php echo $title_for_layout; ?></title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('amdin.css');
?>
</head>
<body>
<?php
echo $this->Session->flash();
echo $content_for_layout;
echo $this->element('sql_dump');
echo $scripts_for_layout;
?>
</body>
</html>
/app/View/Themed/Mars/webroot/css/admin.css
body
{
background: #FA0;
}
为什么代码进入第11行Layout文件夹下的admin.ctp(echo $ this-&gt; Html-&gt; css('amdin.css');)会返回以下结果:
<link rel="stylesheet" type="text/css" href="/mars/css/amdin.css" />
问题在于链接是否存在。未加载CSS文件,因为该路径中不存在该文件。好吗?
答案 0 :(得分:5)
检查你的拼写......
/应用/视图/主题/火星/根目录/ CSS /一个的 DM 强> in.css
<link rel="stylesheet" type="text/css" href="/mars/css/amdin.css" />
当您包含CSS文件时,“admin”中的字母会被转置...
答案 1 :(得分:3)
admin应该是admin,而不是amdin
编辑:像Farray说的那样。